Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Description
Given the enum:
classColours(Enum): RED=1In 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 of Colours.RED is simple and efficient in 3.10, but involves a lot of indirection and dispatching through the enum.property class in 3.11.
The performance impact is likely to get worse in 3.12, as we optimize more kinds of attributes.
Introduced in c314e60, I believe.
Linked PRs
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Projects
Status
Done
Status
Done