This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients gvanrossum, ncoghlan, njs
Date 2018-01-28.04:48:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1517114891.2.0.467229070634.issue32690@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-01-28 04:48:11ncoghlansetrecipients: + ncoghlan, gvanrossum, njs
2018-01-28 04:48:11ncoghlansetmessageid: <1517114891.2.0.467229070634.issue32690@psf.upfronthosting.co.za>
2018-01-28 04:48:11ncoghlanlinkissue32690 messages
2018-01-28 04:48:10ncoghlancreate