Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 232b085

Browse files
miss-islingtonnicky-engethanfurmanhugovk
authored
[3.11] gh-105535 Document potential performance trap during enum creation (GH-107119) (GH-116512)
(cherry picked from commit 601f3a7) Co-authored-by: Nicolas A. Oyarzabal <[email protected]> Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 3abf267 commit 232b085

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Doc/library/enum.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,20 @@ Data Types
270270
>>> Color.RED.value
271271
1
272272

273+
Value of the member, can be set in :meth:`~object.__new__`.
274+
273275
.. note:: Enum member values
274276

275277
Member values can be anything: :class:`int`, :class:`str`, etc. If
276278
the exact value is unimportant you may use :class:`auto` instances and an
277279
appropriate value will be chosen for you. See :class:`auto` for the
278280
details.
279281

282+
While mutable/unhashable values, such as :class:`dict`, :class:`list` or
283+
a mutable :class:`~dataclasses.dataclass`, can be used, they will have a
284+
quadratic performance impact during creation relative to the
285+
total number of mutable/unhashable values in the enum.
286+
280287
.. attribute:: Enum._name_
281288

282289
Name of the member.

0 commit comments

Comments
 (0)