A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-January/070682.html below:

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

[Python-Dev] Deletion order when leaving a scope? [Python-Dev] Deletion order when leaving a scope?Josiah Carlson jcarlson at uci.edu
Thu Jan 18 03:38:41 CET 2007
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?

If you are talking about the locals in the scope of a function, it is an
artifact of how the locals array is created.  That is to say, the locals
of a function are a flat array, and are decref'd in-order.  That
ordering is the original assignment ordering in the function, which is
an artifact of how the compiler goes from local name -> FAST_LOCALS
index.  I don't believe it is an "important feature", but to decref in
any other order would be silly and/or unintuitive.


 - Josiah

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4