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 ethan.furman
Recipients craigh, ethan.furman
Date 2015-02-19.23:41:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1424389275.6.0.260115687972.issue23486@psf.upfronthosting.co.za>
In-reply-to
Content
Yup, you have it figured out.  It's the lookup that is the slowdown.

When performance is an issue one of the standard tricks is to create a local name, like you did with "tiny = Category.tiny".

For the curious (taken from the docstring for Enum.__getattr__):

    We use __getattr__ instead of descriptors or inserting into the enum
    class' __dict__ in order to support `name` and `value` being both
    properties for enum members (which live in the class' __dict__) and
    enum members themselves.

It is possible to store all the enum members /except/ for 'name' and 'value' in the class' __dict__, but I'm not sure it's worth the extra complication.
History
Date User Action Args
2015-02-19 23:41:15ethan.furmansetrecipients: + ethan.furman, craigh
2015-02-19 23:41:15ethan.furmansetmessageid: <1424389275.6.0.260115687972.issue23486@psf.upfronthosting.co.za>
2015-02-19 23:41:15ethan.furmanlinkissue23486 messages
2015-02-19 23:41:15ethan.furmancreate