Skip to content

gh-93910: Fix enum performance regression - #94614

Merged
miss-islington merged 5 commits into
python:mainfrom
mdboom:enum-performance
Jul 7, 2022
Merged

miss-islington merged 5 commits into
python:mainfrom
mdboom:enum-performance

Conversation

@mdboom

@mdboom mdboom commented Jul 6, 2022 •

Copy link
Copy Markdown
Contributor

This removes the performance regression in 3.11, at the expense of not fixing
the "bug" that allows accessing values from values
(e.g. Color.RED.BLUE).

Using the benchmark @markshannon presented, the results are:

Version Enum Fast enum Normal class
3.10 2.04 0.59 0.56
3.11 2.78 0.31 0.15
This PR 1.30 0.32 0.16

I share this mostly as information about the source of the regression, as this may be useful. It may be that the lower-risk approach for the beta is just to revert to a previously-known working state.

Automerge-Triggered-By: GH:tiran

This removes the performance regression in 3.11, at the expense of not fixing
the "bug" that allows accessing values from values (e.g. `Color.RED.BLUE`).

@tiran tiran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, excellent work!

I skimmed the docs and could not find a whatsnew or versionchanged entry that mentions the new and now removed behavior.

Comment thread Lib/test/test_enum.py Outdated
Co-authored-by: Christian Heimes <christian@python.org>
@tiran

tiran commented Jul 6, 2022

Copy link
Copy Markdown
Member

Could you please add blurb that mentions the performance regression and the fact that member of member access is permitted again?

@brettcannon brettcannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment formatting change to make, otherwise LGTM.

Comment thread Lib/enum.py Outdated
Co-authored-by: Brett Cannon <brett@python.org>

@tiran tiran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for fixing this release blocker!

@tiran tiran added stdlib Standard Library Python modules in the Lib/ directory needs backport to 3.11 only security fixes labels Jul 6, 2022
@tiran

tiran commented Jul 7, 2022

Copy link
Copy Markdown
Member

@ethanfurman Are you ok with the change for 3.11?

@miss-islington
miss-islington merged commit ed136b9 into python:main Jul 7, 2022
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @mdboom for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 7, 2022
This removes the performance regression in 3.11, **at the expense of not fixing
the "bug" that allows accessing values from values** (e.g. `Color.RED.BLUE`).

Using the benchmark @markshannon [presented](https://github.com/python/cpython/issues/93910GH-issuecomment-1165503032), the results are:

| Version | Enum | Fast enum | Normal class |
| --- | --- | --- | --- |
| 3.10 | 2.04 | 0.59 | 0.56 |
| 3.11 | 2.78 | 0.31 | 0.15 |
| This PR | 1.30 | 0.32 | 0.16 |

I share this mostly as information about the source of the regression, as this may be useful. It may be that the lower-risk approach for the beta is just to revert to a previously-known working state.
(cherry picked from commit ed136b9)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 7, 2022
@bedevere-bot

Copy link
Copy Markdown

GH-94655 is a backport of this pull request to the 3.11 branch.

miss-islington added a commit that referenced this pull request Jul 7, 2022
This removes the performance regression in 3.11, **at the expense of not fixing
the "bug" that allows accessing values from values** (e.g. `Color.RED.BLUE`).

Using the benchmark @markshannon [presented](https://github.com/python/cpython/issues/93910GH-issuecomment-1165503032), the results are:

| Version | Enum | Fast enum | Normal class |
| --- | --- | --- | --- |
| 3.10 | 2.04 | 0.59 | 0.56 |
| 3.11 | 2.78 | 0.31 | 0.15 |
| This PR | 1.30 | 0.32 | 0.16 |

I share this mostly as information about the source of the regression, as this may be useful. It may be that the lower-risk approach for the beta is just to revert to a previously-known working state.
(cherry picked from commit ed136b9)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants