Message236243
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. |
|
Date |
User |
Action |
Args |
2015-02-19 23:41:15 | ethan.furman | set | recipients:
+ ethan.furman, craigh |
2015-02-19 23:41:15 | ethan.furman | set | messageid: <1424389275.6.0.260115687972.issue23486@psf.upfronthosting.co.za> |
2015-02-19 23:41:15 | ethan.furman | link | issue23486 messages |
2015-02-19 23:41:15 | ethan.furman | create | |
|