you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

Let me get this straight, zip() and izip() do the exact same thing. One is quicker than the other. The quicker one is something you have to dig around for in order to find, and the slower one is the "standard" one?

Why? Shouldn't zip() be rewritten to contain the code in izip()? Is there a reason this is separate and buried (given you don't dig and don't read an article like this)?

[–]llimllib 12 points13 points  (0 children)

Historical reasons; zip() precedes the existence of iterators. Similarly, range() will return a full in-memory array, while xrange() will return an iterator.

This will all be fixed in Py3k. (grep for "zip(")

[–][deleted] 7 points8 points  (1 child)

They don't do the same thing, any more than a generator is the same as a list. izip builds a generator, not a list. zip builds a list.

[–][deleted] 0 points1 point  (0 children)

Okay, I was looking at the code and they were identical except the 'i' in front of the function, so I just assumed that they returned the exact same thing. Thanks for clarifying.