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
0ec820fc
Kaydet (Commit)
0ec820fc
authored
Eki 31, 2012
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
only fast-path fromkeys() when the constructor returns a empty dict (closes #16345)
üst
bdf1b9e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
33 deletions
+45
-33
test_dict.py
Lib/test/test_dict.py
+8
-0
NEWS
Misc/NEWS
+3
-0
dictobject.c
Objects/dictobject.c
+34
-33
No files found.
Lib/test/test_dict.py
Dosyayı görüntüle @
0ec820fc
...
@@ -254,6 +254,14 @@ class DictTest(unittest.TestCase):
...
@@ -254,6 +254,14 @@ class DictTest(unittest.TestCase):
d
=
dict
(
zip
(
range
(
6
),
range
(
6
)))
d
=
dict
(
zip
(
range
(
6
),
range
(
6
)))
self
.
assertEqual
(
dict
.
fromkeys
(
d
,
0
),
dict
(
zip
(
range
(
6
),
[
0
]
*
6
)))
self
.
assertEqual
(
dict
.
fromkeys
(
d
,
0
),
dict
(
zip
(
range
(
6
),
[
0
]
*
6
)))
class
baddict3
(
dict
):
def
__new__
(
cls
):
return
d
d
=
{
i
:
i
for
i
in
range
(
10
)}
res
=
d
.
copy
()
res
.
update
(
a
=
None
,
b
=
None
,
c
=
None
)
self
.
assertEqual
(
baddict3
.
fromkeys
({
"a"
,
"b"
,
"c"
}),
res
)
def
test_copy
(
self
):
def
test_copy
(
self
):
d
=
{
1
:
1
,
2
:
2
,
3
:
3
}
d
=
{
1
:
1
,
2
:
2
,
3
:
3
}
self
.
assertEqual
(
d
.
copy
(),
{
1
:
1
,
2
:
2
,
3
:
3
})
self
.
assertEqual
(
d
.
copy
(),
{
1
:
1
,
2
:
2
,
3
:
3
})
...
...
Misc/NEWS
Dosyayı görüntüle @
0ec820fc
...
@@ -12,6 +12,9 @@ Core and Builtins
...
@@ -12,6 +12,9 @@ Core and Builtins
- Issue #14700: Fix buggy overflow checks for large width and precision
- Issue #14700: Fix buggy overflow checks for large width and precision
in string formatting operations.
in string formatting operations.
- Issue #16345: Fix an infinite loop when ``fromkeys`` on a dict subclass
recieved a nonempty dict from the constructor.
- Issue #6074: Ensure cached bytecode files can always be updated by the
- Issue #6074: Ensure cached bytecode files can always be updated by the
user that created them, even when the source file is read-only.
user that created them, even when the source file is read-only.
...
...
Objects/dictobject.c
Dosyayı görüntüle @
0ec820fc
...
@@ -1353,49 +1353,50 @@ dict_fromkeys(PyObject *cls, PyObject *args)
...
@@ -1353,49 +1353,50 @@ dict_fromkeys(PyObject *cls, PyObject *args)
if
(
d
==
NULL
)
if
(
d
==
NULL
)
return
NULL
;
return
NULL
;
if
(
PyDict_CheckExact
(
d
)
&&
PyDict_CheckExact
(
seq
))
{
if
(
PyDict_CheckExact
(
d
)
&&
PyDict_Size
(
d
)
==
0
)
{
PyDictObject
*
mp
=
(
PyDictObject
*
)
d
;
if
(
PyDict_CheckExact
(
seq
))
{
PyObject
*
oldvalue
;
PyDictObject
*
mp
=
(
PyDictObject
*
)
d
;
Py_ssize_t
pos
=
0
;
PyObject
*
oldvalue
;
PyObject
*
key
;
Py_ssize_t
pos
=
0
;
long
hash
;
PyObject
*
key
;
long
hash
;
if
(
dictresize
(
mp
,
Py_SIZE
(
seq
)))
{
Py_DECREF
(
d
);
if
(
dictresize
(
mp
,
Py_SIZE
(
seq
)))
{
return
NULL
;
}
while
(
_PyDict_Next
(
seq
,
&
pos
,
&
key
,
&
oldvalue
,
&
hash
))
{
Py_INCREF
(
key
);
Py_INCREF
(
value
);
if
(
insertdict
(
mp
,
key
,
hash
,
value
))
{
Py_DECREF
(
d
);
Py_DECREF
(
d
);
return
NULL
;
return
NULL
;
}
}
}
return
d
;
}
if
(
PyDict_CheckExact
(
d
)
&&
PyAnySet_CheckExact
(
seq
))
{
while
(
_PyDict_Next
(
seq
,
&
pos
,
&
key
,
&
oldvalue
,
&
hash
))
{
PyDictObject
*
mp
=
(
PyDictObject
*
)
d
;
Py_INCREF
(
key
)
;
Py_ssize_t
pos
=
0
;
Py_INCREF
(
value
)
;
PyObject
*
key
;
if
(
insertdict
(
mp
,
key
,
hash
,
value
))
{
long
hash
;
Py_DECREF
(
d
)
;
return
NULL
;
if
(
dictresize
(
mp
,
PySet_GET_SIZE
(
seq
)))
{
}
Py_DECREF
(
d
);
}
return
NULL
;
return
d
;
}
}
if
(
PyAnySet_CheckExact
(
seq
))
{
PyDictObject
*
mp
=
(
PyDictObject
*
)
d
;
Py_ssize_t
pos
=
0
;
PyObject
*
key
;
long
hash
;
while
(
_PySet_NextEntry
(
seq
,
&
pos
,
&
key
,
&
hash
))
{
if
(
dictresize
(
mp
,
PySet_GET_SIZE
(
seq
)))
{
Py_INCREF
(
key
);
Py_INCREF
(
value
);
if
(
insertdict
(
mp
,
key
,
hash
,
value
))
{
Py_DECREF
(
d
);
Py_DECREF
(
d
);
return
NULL
;
return
NULL
;
}
}
while
(
_PySet_NextEntry
(
seq
,
&
pos
,
&
key
,
&
hash
))
{
Py_INCREF
(
key
);
Py_INCREF
(
value
);
if
(
insertdict
(
mp
,
key
,
hash
,
value
))
{
Py_DECREF
(
d
);
return
NULL
;
}
}
return
d
;
}
}
return
d
;
}
}
it
=
PyObject_GetIter
(
seq
);
it
=
PyObject_GetIter
(
seq
);
...
...
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