Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.1k
Closed
Description
Given the enum:
classColours(Enum):RED=1
In Python 3.9 and 3.10:
>>>Colours.__dict__["RED"]isColours.REDTrue>>>Colours.RED.RED<Colours.RED:1>
In Python 3.11:
>>>Colours.__dict__["RED"]isColours.REDFalse>>>Colours.RED.REDTraceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/home/mark/repos/cpython/Lib/enum.py",line198,in__get__raiseAttributeError(^^^^^^^^^^^^^^^^^^^^^AttributeError:<enum'Colours'>memberhasnoattribute'RED'
While these might seem like minor semantic changes, there is also a large performance impact.
Lookup ofColours.RED is simple and efficient in 3.10, but involves a lot of indirection and dispatching through theenum.property class in 3.11.
The performance impact is likely to get worse in 3.12, as we optimize more kinds of attributes.
Introduced inc314e60, I believe.
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done
Status
Done