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

Calvin Spealman 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
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.

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
> side-effect?
>
>  Cheers,
>
>
>  larry
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/ironfroggy%40gmail.com
>
>
>


-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/



More information about the Python-list mailing list