[Python-Dev] Deletion order when leaving a scope?

Terry Reedy tjreedy at udel.edu
Thu Jan 18 21:45:55 CET 2007


"Paul McGuire" <ptmcg at austin.rr._bogus_.com> wrote in message 
news:45af14dc$0$7727$4c368faf at roadrunner.com...
| "Calvin Spealman" <ironfroggy at gmail.com> wrote in message
| news:mailman.2860.1169086798.32031.python-list at python.org...
| > Absolutely an irrelevent side effect, especially when you take into
| > consideration the 4 and counting alternative implementations of the
| > language.
| >
| > None the less, I can explain why it is as it is, keeping in mind its
| > not like that on purpose, its just how it is. Locals are optimized
| > into an array for fast lookup. Every name assigned to in a function is
| > known as a local in that function and this internal array holds its
| > reference. It is simply a product of the array indexes and deletion
| > order being the same, 0 to N.
| >
|
| Oh good!  Now I can write code that relies on this behavior!

According to a followup on python-dev, you can't.  The above is the normal 
behavior (for CPython) but it can be modified by imports and 
cross-references.

Or did you forget a smiley?

tjr






More information about the Python-list mailing list