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
a3e1ad27
Kaydet (Commit)
a3e1ad27
authored
Kas 30, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 7410: deepcopy of itertools.count() reset the count.
üst
8e319fc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
test_itertools.py
Lib/test/test_itertools.py
+9
-0
itertoolsmodule.c
Modules/itertoolsmodule.c
+17
-1
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
a3e1ad27
...
...
@@ -7,6 +7,8 @@ from fractions import Fraction
import
sys
import
operator
import
random
import
copy
import
pickle
from
functools
import
reduce
maxsize
=
support
.
MAX_Py_ssize_t
minsize
=
-
maxsize
-
1
...
...
@@ -352,6 +354,13 @@ class TestBasicOps(unittest.TestCase):
r2
=
'count(
%
r)'
.
__mod__
(
i
)
.
replace
(
'L'
,
''
)
self
.
assertEqual
(
r1
,
r2
)
# check copy, deepcopy, pickle
for
value
in
-
3
,
3
,
maxsize
-
5
,
maxsize
+
5
:
c
=
count
(
value
)
self
.
assertEqual
(
next
(
copy
.
copy
(
c
)),
value
)
self
.
assertEqual
(
next
(
copy
.
deepcopy
(
c
)),
value
)
self
.
assertEqual
(
next
(
pickle
.
loads
(
pickle
.
dumps
(
c
))),
value
)
def
test_count_with_stride
(
self
):
self
.
assertEqual
(
lzip
(
'abc'
,
count
(
2
,
3
)),
[(
'a'
,
2
),
(
'b'
,
5
),
(
'c'
,
8
)])
self
.
assertEqual
(
lzip
(
'abc'
,
count
(
start
=
2
,
step
=
3
)),
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
a3e1ad27
...
...
@@ -3049,6 +3049,22 @@ count_repr(countobject *lz)
lz
->
long_cnt
,
lz
->
long_step
);
}
static
PyObject
*
count_reduce
(
countobject
*
lz
)
{
if
(
lz
->
cnt
==
PY_SSIZE_T_MAX
)
return
Py_BuildValue
(
"O(OO)"
,
Py_TYPE
(
lz
),
lz
->
long_cnt
,
lz
->
long_step
);
return
Py_BuildValue
(
"O(n)"
,
Py_TYPE
(
lz
),
lz
->
cnt
);
}
PyDoc_STRVAR
(
count_reduce_doc
,
"Return state information for pickling."
);
static
PyMethodDef
count_methods
[]
=
{
{
"__reduce__"
,
(
PyCFunction
)
count_reduce
,
METH_NOARGS
,
count_reduce_doc
},
{
NULL
,
NULL
}
/* sentinel */
};
PyDoc_STRVAR
(
count_doc
,
"count(start=0, step=1]) --> count object
\n
\
\n
\
...
...
@@ -3090,7 +3106,7 @@ static PyTypeObject count_type = {
0
,
/* tp_weaklistoffset */
PyObject_SelfIter
,
/* tp_iter */
(
iternextfunc
)
count_next
,
/* tp_iternext */
0
,
/* tp_methods */
count_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
...
...
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