Nick Coghlan <ncogh...@gmail.com> added the comment:

The current oddity where the names will always appear in the reverse of 
declaration order comes from a C level loop in the frame object's "map_to_dict" 
helper function that loops in reverse [1]:

    ...
    for (j = nmap; --j >= 0; ) {
        ...
    }

While I haven't tried reversing that yet, I haven't found anything to indicate 
that it *needs* to be a reverse iteration - it looks like Guido just wrote it 
that way back in 1994 [2], and everyone that touched the code since then 
preserved the original iteration order since they didn't have a compelling 
reason to change it.


[1] https://github.com/python/cpython/blob/master/Objects/frameobject.c#L794
[2] 
https://github.com/python/cpython/commit/1d5735e84621a7fe68d361fa0e289fa2c3310836

----------
nosy: +ncoghlan

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32690>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to