[Python-Dev] Why are captured parameters also listed in co_varnames? (original) (raw)
Andrea Griffini agriff at tin.it
Tue Jul 2 11:27:02 CEST 2013
- Previous message: [Python-Dev] End of the mystery "@README.txt Mercurial bug"
- Next message: [Python-Dev] Why are captured parameters also listed in co_varnames?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm trying to understand how CPython implements closure variable capture and there is one minor point I can't understand.
When a local is captured it gets allocated in co_cellvars and is accessed with (LOAD|STORE)_DEREF, and this is clear. However when a local is coming from a parameter it gets ALSO allocated in co_varnames even if the local slot apparently is not accesible because *_FAST opcodes are not generated.
Is there a technical reason for this? It happens in CPython 2, 3 and even in PyPy...
Andrea Griffini -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130702/d86dd488/attachment.html>
- Previous message: [Python-Dev] End of the mystery "@README.txt Mercurial bug"
- Next message: [Python-Dev] Why are captured parameters also listed in co_varnames?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]