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
be53242f
Kaydet (Commit)
be53242f
authored
Şub 21, 2003
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove _reduce_2, it's now implemented in C.
üst
2bc4a47c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
42 deletions
+5
-42
copy_reg.py
Lib/copy_reg.py
+5
-42
No files found.
Lib/copy_reg.py
Dosyayı görüntüle @
be53242f
...
...
@@ -45,7 +45,10 @@ def _reconstructor(cls, base, state):
_HEAPTYPE
=
1
<<
9
def
_reduce
(
self
):
# Python code for object.__reduce_ex__ for protocols 0 and 1
def
_reduce_ex
(
self
,
proto
):
assert
proto
<
2
for
base
in
self
.
__class__
.
__mro__
:
if
hasattr
(
base
,
'__flags__'
)
and
not
base
.
__flags__
&
_HEAPTYPE
:
break
...
...
@@ -75,51 +78,11 @@ def _reduce(self):
else
:
return
_reconstructor
,
args
#
A better version of _reduce, used by copy and pickle
protocol 2
#
Helper for __reduce_ex__
protocol 2
def
__newobj__
(
cls
,
*
args
):
return
cls
.
__new__
(
cls
,
*
args
)
def
_reduce_2
(
obj
):
cls
=
obj
.
__class__
getnewargs
=
getattr
(
obj
,
"__getnewargs__"
,
None
)
if
getnewargs
:
args
=
getnewargs
()
else
:
args
=
()
getstate
=
getattr
(
obj
,
"__getstate__"
,
None
)
if
getstate
:
state
=
getstate
()
else
:
state
=
getattr
(
obj
,
"__dict__"
,
None
)
names
=
_slotnames
(
cls
)
if
names
:
slots
=
{}
nil
=
[]
for
name
in
names
:
value
=
getattr
(
obj
,
name
,
nil
)
if
value
is
not
nil
:
slots
[
name
]
=
value
if
slots
:
state
=
(
state
,
slots
)
listitems
=
dictitems
=
None
if
isinstance
(
obj
,
list
):
listitems
=
iter
(
obj
)
elif
isinstance
(
obj
,
dict
):
dictitems
=
obj
.
iteritems
()
return
__newobj__
,
(
cls
,)
+
args
,
state
,
listitems
,
dictitems
# Extended reduce:
def
_reduce_ex
(
obj
,
proto
=
0
):
obj_reduce
=
getattr
(
obj
,
"__reduce__"
,
None
)
if
obj_reduce
and
obj
.
__class__
.
__reduce__
is
not
object
.
__reduce__
:
return
obj_reduce
()
elif
proto
<
2
:
return
_reduce
(
obj
)
else
:
return
_reduce_2
(
obj
)
def
_slotnames
(
cls
):
"""Return a list of slot names for a given class.
...
...
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