GeezerVison is showing github.com — gh-118761: Use `enum._simple_enum` for `annotationlib.Format` by AA-Turner · Pull Request #132031 · python/cpython
Conversation
AA-Turner
commented
Apr 2, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
We can use the internal _simple_enum class decorator here, for slight faster enum creation. I don't think there's any good way to entirely avoid/defer the enum import, though.
A
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I'm not a fan of using private functionality here; I'd rather this enum work the same way as an equivalent user-created way. If we think this is the right way to make an enum, we should make this decorator public.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
My understanding is it's an intentionally internal-only decorator (eg used in ast and re). @ethanfurman is probably best placed to comment.
A
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
All commit authors signed the Contributor License Agreement.

|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I don't want to do this. If we think creating enum classes is too slow, we should make a public API for faster enums.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Creating enums with EnumType is definitely slower, and _simple_enum was created for stdlib use for areas where every bit of performance was desired (such as in enum.py itself, re, and a few others).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
JelleZijlstra
Awaiting requested review from JelleZijlstra
JelleZijlstra is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.