zip broken?

Steven Taschuk staschuk at
Sun Jun 8 02:30:39 CEST 2003

Quoth Marek "Baczek" Baczyñski:
> I found a behaviour of zip() which I don't like -- it hangs on
> infinite generators. [...]

Well, yes.  zip() returns a list; obviously it must gather all the
items and put them in the list before returning it.  Calling it
"broken" because it can't build an infinite list is a bit silly.

If you want a zip which returns an iterator (and which can be used
with infinite sequences), then see itertools.izip (new in Python

Steven Taschuk                                     staschuk at
Receive them ignorant; dispatch them confused.  (Weschler's Teaching Motto)

More information about the Python-list mailing list