summaryrefslogtreecommitdiffstats
path: root/Misc/NEWS.d
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2021-10-14 20:59:51 (GMT)
committerGitHub <noreply@github.com>2021-10-14 20:59:51 (GMT)
commitb2af211e229df941d9b404f69547a264115156b5 (patch)
tree7419794a48171aa351ce7ebb1510bcf6408b2cde /Misc/NEWS.d
parent0bbea0723ee07f9d7ad9745f0e1875718ef38715 (diff)
downloadcpython-b2af211e229df941d9b404f69547a264115156b5.zip
cpython-b2af211e229df941d9b404f69547a264115156b5.tar.gz
cpython-b2af211e229df941d9b404f69547a264115156b5.tar.bz2
bpo-45417: [Enum] fix quadratic behavior during creation (GH-28907)
Creating an Enum exhibited quadratic behavior based on the number of members in three places: - `EnumDict._member_names`: a list searched with each new member's name - member creation: a `for` loop checking each existing member to see if new member was a duplicate - `auto()` values: a list of all previous values in enum was copied before being sent to `_generate_next_value()` Two of those issues have been resolved: - `_EnumDict._member_names` is now a dictionary so lookups are fast - member creation tries a fast value lookup before falling back to the slower `for` loop lookup The third issue still remains, as `_generate_next_value_()` can be user-overridden and could corrupt the last values list if it were not copied.
Diffstat (limited to 'Misc/NEWS.d')
-rw-r--r--Misc/NEWS.d/next/Library/2021-10-12-20-35-06.bpo-45417.gQM-O7.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-10-12-20-35-06.bpo-45417.gQM-O7.rst b/Misc/NEWS.d/next/Library/2021-10-12-20-35-06.bpo-45417.gQM-O7.rst
new file mode 100644
index 0000000..a15c239
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-10-12-20-35-06.bpo-45417.gQM-O7.rst
@@ -0,0 +1,2 @@
+Fix quadratic behaviour in the enum module: Creation of enum classes with a
+lot of entries was quadratic.