Skip to content

Commit

Permalink
pythongh-105535 Document potential performance trap during enum creat…
Browse files Browse the repository at this point in the history
…ion (pythonGH-107119)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
  • Loading branch information
3 people authored and adorilson committed Mar 25, 2024
1 parent c8dbfcf commit 6ea639c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,20 @@ Data Types
>>> Color.RED.value
1

Value of the member, can be set in :meth:`~object.__new__`.

.. note:: Enum member values

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

While mutable/unhashable values, such as :class:`dict`, :class:`list` or
a mutable :class:`~dataclasses.dataclass`, can be used, they will have a
quadratic performance impact during creation relative to the
total number of mutable/unhashable values in the enum.

.. attribute:: Enum._name_

Name of the member.
Expand Down

0 comments on commit 6ea639c

Please sign in to comment.