zip() function troubles

Istvan Albert istvan.albert at gmail.com
Fri Jul 27 03:25:00 CEST 2007


On Jul 26, 7:44 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Istvan Albert <istvan.alb... at gmail.com> writes:
> > exceeded 10 million the zip function slowed to a crawl. Note that
> > there was memory available to store over 100 million items.
>
> How many bytes is that?  Maybe the items (heap-allocated boxed
> integers in your code example) are bigger than you expect.

while I don't have an answer to this

the point that I was trying to make is that I'm fairly certain that it
is not a memory issue (some sort of swapping) because the overall
memory usage with the OS included is about 1Gb (out of available 2Gb)

I tested this on a linux server system with 4Gb of RAM

a = [ 0 ] * 10**7

takes miliseconds, but say the

b = zip(a,a)

will take a very long time to finish:

atlas:~$ time python -c "a = [0] * 10**7"

real    0m0.165s
user    0m0.128s
sys     0m0.036s
atlas:~$ time python -c "a = [0] * 10**7; b= zip(a,a)"

real    0m55.150s
user    0m54.919s
sys     0m0.232s

Istvan




More information about the Python-list mailing list