Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e57f91a0
Unverified
Kaydet (Commit)
e57f91a0
authored
Haz 18, 2018
tarafından
INADA Naoki
Kaydeden (comit)
GitHub
Haz 18, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33866: enum: Stop using OrderedDict (GH-7698)
üst
ea3dc802
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
15 deletions
+7
-15
enum.rst
Doc/library/enum.rst
+2
-2
enum.py
Lib/enum.py
+5
-13
No files found.
Doc/library/enum.rst
Dosyayı görüntüle @
e57f91a0
...
...
@@ -281,7 +281,7 @@ Iterating over the members of an enum does not provide the aliases::
>>> list(Shape)
[<Shape.SQUARE: 2>, <Shape.DIAMOND: 1>, <Shape.CIRCLE: 3>]
The special attribute ``__members__`` is a
n ordered dictionary mapping
names
The special attribute ``__members__`` is a
read-only ordered mapping of
names
to members. It includes all names defined in the enumeration, including the
aliases::
...
...
@@ -998,7 +998,7 @@ Finer Points
Supported ``__dunder__`` names
""""""""""""""""""""""""""""""
:attr:`__members__` is a
n :class:`OrderedDict`
of ``member_name``:``member``
:attr:`__members__` is a
read-only ordered mapping
of ``member_name``:``member``
items. It is only available on the class.
:meth:`__new__`, if specified, must create and return the enum members; it is
...
...
Lib/enum.py
Dosyayı görüntüle @
e57f91a0
import
sys
from
types
import
MappingProxyType
,
DynamicClassAttribute
# try _collections first to reduce startup cost
try
:
from
_collections
import
OrderedDict
except
ImportError
:
from
collections
import
OrderedDict
__all__
=
[
'EnumMeta'
,
...
...
@@ -168,7 +162,7 @@ class EnumMeta(type):
# create our new Enum type
enum_class
=
super
()
.
__new__
(
metacls
,
cls
,
bases
,
classdict
)
enum_class
.
_member_names_
=
[]
# names in definition order
enum_class
.
_member_map_
=
OrderedDict
()
# name->value map
enum_class
.
_member_map_
=
{}
# name->value map
enum_class
.
_member_type_
=
member_type
# save attributes from super classes so we know if we can take
...
...
@@ -630,14 +624,12 @@ class Enum(metaclass=EnumMeta):
source
=
vars
(
source
)
else
:
source
=
module_globals
# We use an OrderedDict of sorted source keys so that the
# _value2member_map is populated in the same order every time
# _value2member_map_ is populated in the same order every time
# for a consistent reverse mapping of number to name when there
# are multiple names for the same number rather than varying
# between runs due to hash randomization of the module dictionary.
# are multiple names for the same number.
members
=
[
(
name
,
source
[
name
]
)
for
name
in
source
.
key
s
()
(
name
,
value
)
for
name
,
value
in
source
.
item
s
()
if
filter
(
name
)]
try
:
# sort by value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment