FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-118761: Use `enum._simple_enum` for `annotationlib.Format` by AA-Turner · Pull Request #132031 · python/cpython · GitHub

/ cpython Public

gh-118761: Use enum._simple_enum for annotationlib.Format - #132031

Closed
AA-Turner wants to merge 1 commit into
python:mainfrom
AA-Turner:annotationlib-simple-enum
Closed

gh-118761: Use enum._simple_enum for annotationlib.Format#132031
AA-Turner wants to merge 1 commit into
python:mainfrom
AA-Turner:annotationlib-simple-enum

Conversation

AA-Turner commented Apr 2, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

My understanding is it's an intentionally internal-only decorator (eg used in ast and re). @ethanfurman is probably best placed to comment.

A

python-cla-bot Bot commented Apr 6, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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).

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL