]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-93910: Fix enum performance regression (GH-94614)
authorMichael Droettboom <mdboom@gmail.com>
Thu, 7 Jul 2022 11:26:56 +0000 (07:26 -0400)
committerGitHub <noreply@github.com>
Thu, 7 Jul 2022 11:26:56 +0000 (04:26 -0700)
commited136b96737fdbeff864079d12904cb962c6cce5
treef8ec5bc48b2fdf0362d95c8d3f62b7a956d9b2c5
parent277f55cb04409ccdf651d43df5eb9dcb3ee3128c
gh-93910: Fix enum performance regression (GH-94614)

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/93910#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.
Lib/enum.py
Lib/test/test_enum.py
Misc/NEWS.d/next/Library/2022-07-06-14-45-12.gh-issue-93910.iZcp67.rst [new file with mode: 0644]