8000 gh-105535 Document potential performance trap during enum creation (G… · python/cpython@601f3a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 601f3a7

Browse files
nicky-engethanfurmanhugovk
authored
gh-105535 Document potential performance trap during enum creation (GH-107119)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 735fc2c commit 601f3a7

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
@@ -279,13 +279,20 @@ Data Types
279279
>>> Color.RED.value
280280
1
281281

282+
Value of the member, can be set in :meth:`~object.__new__`.
283+
282284
.. note:: Enum member values
283285

284286
Member values can be anything: :class:`int`, :class:`str`, etc. If
285287
the exact value is unimportant you may use :class:`auto` instances and an
286288
appropriate value will be chosen for you. See :class:`auto` for the
287289
details.
288290

291+
While mutable/unhashable values, such as :class:`dict`, :class:`list` or
292+
a mutable :class:`~dataclasses.dataclass`, can be used, they will have a
293+
quadratic performance impact during creation relative to the
294+
total number of mutable/unhashable values in the enum.
295+
289296
.. attribute:: Enum._name_
290297

291298
Name of the member.

0 commit comments

Comments
 (0)
0