GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-153981: Fix use after free bug itertools.count() by johng · Pull Request #153983 · python/cpython Conversation
|
|
This appears to add some very slight overhead to repr in slow mode, no impact to the likely more heavily used fast mode |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Performances are not really inportant for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <[email protected]>
|
@picnixz would you be able to kindly review again, thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@picnixz kindly pining for a re-review, thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It may just seem dumb but since __repr__ is fairly used just for debugging, I don't think we really need to worry about performances; so why not just having everything in a critical section? would that work?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Would that not risk locking other threads executing more latency sensitive functions that are holding the lock? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We don't care here IMO. If you print the counter, just expect it to possbly be slow. And can you simply benchmark this please? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
If I add a lock around the whole of repr I can significantly slow down the actual counting module if another thread is printing. I'm sure this example is a bit contrived however I think a real possibility another thread printing could slow down the counting module.
simple_bench.py (see below) DetailsAnd just to confirm a lock held across repr would look something like this |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Two possibilities:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I'm not sure if this was what you were after but I think this reduces the branches considerably if the if/else branches were the main sticking point. Agree looking back it was rather messy for all the approaches! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| lz->long_cnt, lz->long_step); | ||
|
|
||
| /* Don't display step when it is an integer equal to 1 */ | ||
| msg = PyUnicode_FromFormat(step == 1 ? "%s(%R)" : "%s(%R, %R)", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can put PyObject *msg = here instead.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /* Don't display step when it is an integer equal to 1 */ | ||
| msg = PyUnicode_FromFormat(step == 1 ? "%s(%R)" : "%s(%R, %R)", | ||
| _PyType_Name(Py_TYPE(lz)), | ||
| long_cnt, lz->long_step); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we have the if check out of the format call? I don't exactly remember but I think passing more va args than what the format expects is UB>
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.