GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

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

Uh oh!

There was an error while loading. Please reload this page.

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

  • Issue: Improve import time of various stdlib modules #118761

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AA-Turner
Use enum._simple_enum for annotationlib.Format
2305ab8
@AA-Turner AA-Turner added performance Performance or resource usage skip news labels Apr 2, 2025
@AA-Turner
AA-Turner requested a review from JelleZijlstra as a code owner April 2, 2025 19:17
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 2, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 2, 2025
Improve import time of various stdlib modules #118761
Closed
@JelleZijlstra

JelleZijlstra commented Apr 3, 2025

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Apr 3, 2025

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@python-cla-bot

python-cla-bot Bot commented Apr 6, 2025

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented May 4, 2025

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra JelleZijlstra closed this May 4, 2025
@ethanfurman

ethanfurman commented May 4, 2025

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra 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

Labels

awaiting core review performance Performance or resource usage skip news

Projects

None yet

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.

3 participants

@AA-Turner @JelleZijlstra @ethanfurman
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.