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-120906: Support arbitrary hashable keys in FrameLocalsProxy by encukou · Pull Request #122309 · python/cpython Conversation
|
|
So for the first glance, there are two questions:
I did no go through the whole change because I don't believe we've reached to the point where we agree how to do this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
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.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
General approach LGTM, some suggestions inline regarding test case details.
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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Alyssa Coghlan <[email protected]>
| for (int i = 0; i < co->co_nlocalsplus; i++) { | ||
| PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i); | ||
| if (name == key) { | ||
| found_key = true; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If you removed found_key check here, maybe just return -1 if the condition does not meet. Otherwise it will go through the loop again and check something we already knew.
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.
The rest of the PR LGTM.
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.
Right, thanks for the catch!
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.
Could you check the change?
I'm still not too familiar with the internals of this mapping; I just found out (hopefully correctly) what the undocumented CO_FAST_HIDDEN does.
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.
The change looks correct to me (with the search flag restored, the CO_FAST_HIDDEN handling is unchanged from @gaogaotiantian's original PR).
I did suggest an explanatory comment on the early return, but that's definitely not a merge blocker. So even if @gaogaotiantian doesn't get time to take a look, I think this is good to go for rc1.
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 a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Capturing my understanding of the CO_FAST_HIDDEN handling, since it's genuinely not clear:
sys._getframe().f_locals produces fast locals proxy instances during iteration (writes to hidden variables go into the frame's "extra locals" storage rather than modifying the comprehension iteration variable)Future versions could revisit that design if debugger developers ask for it to change, but live editing loop variables seems sufficiently fraught with peril that I'll be genuinely surprised if anyone ever notices this small discrepancy between module level comprehensions and function level ones.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Alyssa Coghlan <[email protected]>
|
@gaogaotiantian and/or @markshannon, your review would be appreciated, so we can get this in 3.13. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks good. There is one test I'd like to added, though. but it doesn't seem like there is a test for this case (writing a fast local using a non-str key). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Will do in ~6 hours, feel free to beat me to it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Test added. (There was one for writing a fast local using a non-str key, but not for writing a so far uninitialized local like your example, so I added that.) Thank you for the reviews! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @encukou, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…sProxy (pythonGH-122309) Co-authored-by: Alyssa Coghlan <[email protected]> (cherry picked from commit 5912487)
…sProxy (pythonGH-122309) Co-authored-by: Alyssa Coghlan <[email protected]> (cherry picked from commit 5912487)
|
GH-122488 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…GH-122309) (#122488) [3.13] gh-120906: Support arbitrary hashable keys in FrameLocalsProxy (GH-122309) Co-authored-by: Alyssa Coghlan <[email protected]> (cherry picked from commit 5912487)
…pythonGH-122309) Co-authored-by: Alyssa Coghlan <[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.