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
b5a42088
Kaydet (Commit)
b5a42088
authored
Agu 08, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Modified itertools.izip() to match the behavior of __builtin__.zip()
which can now take zero arguments.
üst
77fe69bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
libitertools.tex
Doc/lib/libitertools.tex
+4
-1
test_itertools.py
Lib/test/test_itertools.py
+6
-1
NEWS
Misc/NEWS
+3
-0
itertoolsmodule.c
Modules/itertoolsmodule.c
+2
-6
No files found.
Doc/lib/libitertools.tex
Dosyayı görüntüle @
b5a42088
...
...
@@ -226,10 +226,13 @@ by functions or loops that truncate the stream.
\begin{verbatim}
def izip(*iterables):
iterables = map(iter, iterables)
while
True
:
while
iterables
:
result = [i.next() for i in iterables]
yield tuple(result)
\end{verbatim}
\versionchanged
[When no iterables are specified, returns a zero length
iterator instead of raising a TypeError exception]
{
2.4
}
\end{funcdesc}
\begin{funcdesc}
{
repeat
}{
object
\optional
{
, times
}}
...
...
Lib/test/test_itertools.py
Dosyayı görüntüle @
b5a42088
...
...
@@ -87,7 +87,7 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
list
(
izip
(
'abcdef'
,
range
(
3
))),
zip
(
'abcdef'
,
range
(
3
)))
self
.
assertEqual
(
take
(
3
,
izip
(
'abcdef'
,
count
())),
zip
(
'abcdef'
,
range
(
3
)))
self
.
assertEqual
(
list
(
izip
(
'abcdef'
)),
zip
(
'abcdef'
))
self
.
assert
Raises
(
TypeError
,
izip
)
self
.
assert
Equal
(
list
(
izip
()),
zip
()
)
self
.
assertRaises
(
TypeError
,
izip
,
3
)
self
.
assertRaises
(
TypeError
,
izip
,
range
(
3
),
3
)
# Check tuple re-use (implementation detail)
...
...
@@ -199,6 +199,8 @@ class TestBasicOps(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
dropwhile
(
errfunc
,
[(
4
,
5
)])
.
next
)
def
test_StopIteration
(
self
):
self
.
assertRaises
(
StopIteration
,
izip
()
.
next
)
for
f
in
(
chain
,
cycle
,
izip
):
self
.
assertRaises
(
StopIteration
,
f
([])
.
next
)
self
.
assertRaises
(
StopIteration
,
f
(
StopNow
())
.
next
)
...
...
@@ -540,6 +542,9 @@ True
>>> no(lambda x: x
%2
==0, [1, 2, 5, 9])
False
>>> quantify(lambda x: x
%2
==0, xrange(99))
50
>>> list(window('abc'))
[('a', 'b'), ('b', 'c')]
...
...
Misc/NEWS
Dosyayı görüntüle @
b5a42088
...
...
@@ -23,6 +23,9 @@ Extension modules
Library
-------
- itertools.izip() with no arguments now returns an empty iterator instead
of raising a TypeError exception.
- _strptime.py now has a behind-the-scenes caching mechanism for the most
recent TimeRE instance used along with the last five unique directive
patterns. The overall module was also made more thread-safe.
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
b5a42088
...
...
@@ -1510,12 +1510,6 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject
*
result
;
int
tuplesize
=
PySequence_Length
(
args
);
if
(
tuplesize
<
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"izip() requires at least one sequence"
);
return
NULL
;
}
/* args must be a tuple */
assert
(
PyTuple_Check
(
args
));
...
...
@@ -1598,6 +1592,8 @@ izip_next(izipobject *lz)
PyObject
*
it
;
PyObject
*
item
;
if
(
tuplesize
==
0
)
return
NULL
;
if
(
result
->
ob_refcnt
==
1
)
{
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
...
...
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