[Python-Dev] Deletion order when leaving a scope?
ironfroggy at gmail.com
Thu Jan 18 03:19:52 CET 2007
Absolutely an irrelevent side effect, especially when you take into
consideration the 4 and counting alternative implementations of the
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.
On 1/17/07, Larry Hastings <larry at hastings.org> wrote:
> I just ran a quickie experiment and determined: when leaving a scope,
> variables are deleted FIFO, aka in the same order they were created. This
> surprised me; I'd expected them to be deleted LIFO, aka last first. Why is
> it thus? Is this behavior an important feature or an irrelevant
> Python-Dev mailing list
> Python-Dev at python.org
Read my blog! I depend on your acceptance of my opinion! I am interesting!
More information about the Python-list