Is this a bug? Python intermittently stops dead for seconds

Tim Peters tim.peters at gmail.com
Sun Oct 1 22:12:11 CEST 2006


[charlie strauss]
> Below is a simple program that will cause python to intermittently
> stop executing for a few seconds.  it's 100% reproducible on my machine.

Any program that creates a great many long-lived container objects
will behave similarly during the creation phase.  Others have
explained why.  Here's a simpler example:

from time import time
xs = []
i = 0
while 1:
    i += 1
    s = time()
    xs.append([[1, 2] for dummy in xrange(1000)])
    f = time()
    if f-s > 0.25:
        print "time", f-s, "on try", i
    if i % 100 == 0:
        print "xs made:", i



More information about the Python-list mailing list