zip broken?

Steven Taschuk staschuk at telusplanet.net
Sat Jun 7 20:30:39 EDT 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
2.3).

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





More information about the Python-list mailing list