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-154594: Fix deepcopy memo lookup when __deepcopy__ returns None by tonghuaroot · Pull Request #154595 · python/cpython Conversation
|
|
Switched to Microbenchmark (5M lookups): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Faster in both cases? Did you measure purely |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The earlier numbers included the surrounding statements. Measuring just the lookup, each returning the value (best of 5 runs of 10M): So |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok if the surrounding stuff was properly included, then that's good. This new comparison for "just the lookup" is not, it's missing the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Anyway, I agree that misses are probably the common case, and I'm not surprised if full deepcopy timings are within noise either way, as deepcopy is rather slow. |
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.
Two small nits, but this looks good to me.
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.
pochmann benchmarked this issue's candidate fixes on pythongh-154594 and found the try/except form is ~3.5x slower on a memo miss (the common case in real deepcopy workloads) despite being fastest on a hit. `d in memo` ties or beats the current `is not None` check on both hit and miss, and matches where the competing PR (pythongh-154595) landed after the same discussion.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The code is a bit cleaner, a bit faster and it solves a (minor) bug.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @tonghuaroot for the PR, and @eendebakpt for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-159255 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…None (GH-154595) (#159255) gh-154594: Fix deepcopy memo lookup when __deepcopy__ returns None (GH-154595) * gh-154594: Fix deepcopy memo lookup when __deepcopy__ returns None * Use 'd in memo' lookup instead of a sentinel Addresses review: clearer, no sentinel, and the test treats memo as opaque. * Apply review suggestions: shorten NEWS, use class attribute in test --------- (cherry picked from commit 5539c2a) Co-authored-by: tonghuaroot (童话) <[email protected]> Co-authored-by: Pieter Eendebak <[email protected]>
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.