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
d1388921
Unverified
Kaydet (Commit)
d1388921
authored
Ock 07, 2018
tarafından
Eric V. Smith
Kaydeden (comit)
GitHub
Ock 07, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32506: Change dataclasses from OrderedDict to plain dict. (gh-5131)
üst
b216a253
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
dataclasses.py
Lib/dataclasses.py
+8
-8
2018-01-07-11-32-42.bpo-32506.MaT-zU.rst
...S.d/next/Library/2018-01-07-11-32-42.bpo-32506.MaT-zU.rst
+2
-0
No files found.
Lib/dataclasses.py
Dosyayı görüntüle @
d1388921
import
sys
import
types
from
copy
import
deepcopy
import
collections
import
inspect
__all__
=
[
'dataclass'
,
...
...
@@ -448,11 +447,11 @@ def _set_attribute(cls, name, value):
def
_process_class
(
cls
,
repr
,
eq
,
order
,
hash
,
init
,
frozen
):
#
Use an OrderedDict because:
#
- Order matters!
#
- Derived class fields overwrite base class fields, but the
#
order
is defined by the base class, which is found first.
fields
=
collections
.
OrderedDict
()
#
Now that dicts retain insertion order, there's no reason to use
#
an ordered dict. I am leveraging that ordering here, because
#
derived class fields overwrite base class fields, but the order
# is defined by the base class, which is found first.
fields
=
{}
# Find our base classes in reverse MRO order, and exclude
# ourselves. In reversed order so that more derived classes
...
...
@@ -612,7 +611,8 @@ def fields(class_or_instance):
except
AttributeError
:
raise
TypeError
(
'must be called with a dataclass type or instance'
)
# Exclude pseudo-fields.
# Exclude pseudo-fields. Note that fields is sorted by insertion
# order, so the order of the tuple is as the fields were defined.
return
tuple
(
f
for
f
in
fields
.
values
()
if
f
.
_field_type
is
_FIELD
)
...
...
@@ -735,7 +735,7 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
# Copy namespace since we're going to mutate it.
namespace
=
namespace
.
copy
()
anns
=
collections
.
OrderedDict
()
anns
=
{}
for
item
in
fields
:
if
isinstance
(
item
,
str
):
name
=
item
...
...
Misc/NEWS.d/next/Library/2018-01-07-11-32-42.bpo-32506.MaT-zU.rst
0 → 100644
Dosyayı görüntüle @
d1388921
Now that dict is defined as keeping insertion order, drop OrderedDict and
just use plain dict.
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