8000 [3.12] gh-105535 Document potential performance trap during enum crea… · python/cpython@d5d86e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d5d86e2

Browse files
miss-islingtonnicky-engethanfurmanhugovk
authored
[3.12] gh-105535 Document potential performance trap during enum creation (GH-107119) (GH116511)
(cherry picked from commit 601f3a7) Co-authored-by: Nicolas A. Oyarzabal <79150521+nicky-eng@users.noreply.github.com> Co-authored-by: Ethan Furman <ethan@stoneleaf.us> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 2647afe commit d5d86e2

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
@@ -269,13 +269,20 @@ Data Types
269269
>>> Color.RED.value
270270
1
271271

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

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

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

281288
Name of the member.

0 commit comments

Comments
 (0)
0