KEMBAR78
gh-95077: [Enum] add code-based deprecation warnings for member.member access by ethanfurman · Pull Request #95083 · python/cpython · GitHub
Skip to content

Conversation

@ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Jul 21, 2022

The performance speed-up added in 3.11 is removed as other improvements in Python have made it unnecessary. With that removal, it is now possible to detect when a member.member access is attempted, and issue a warning before returning the desired member.


Each enum member is represented in the enum class dict by a custom enum.property. The enum member itself lives in both _member_map_ and enum.property, enabling enum.property to skip the _member_map_ lookup.

enum.property is a subclass of types.DynamicClassAttribute to enable inspect, etc., to properly investigate and document enum members and attributes (although enum.property works completely differently).

@ethanfurman ethanfurman self-assigned this Jul 21, 2022
@ethanfurman ethanfurman added type-feature A feature request or enhancement 3.12 only security fixes stdlib Standard Library Python modules in the Lib/ directory labels Jul 21, 2022
@ethanfurman ethanfurman merged commit 4e704d7 into python:main Jul 25, 2022
@ethanfurman ethanfurman deleted the enum-restricted branch November 23, 2022 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.12 only security fixes stdlib Standard Library Python modules in the Lib/ directory type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants