In message <7xiq2que93....@ruckus.brouhaha.com>, Paul Rubin wrote: > Lawrence D'Oliveiro <l...@geek-central.gen.new_zealand> writes: >> >>> Refcounting is susceptable to the same pauses for reasons already >>> discussed. >> >> Doesn’t seem to happen in the real world, though. > > def f(n): > from time import time > a = [1] * n > t0 = time() > del a > t1 = time() > return t1 - t0 > > for i in range(9): > print i, f(10**i) > > > on my system prints: > > 0 2.86102294922e-06 > 1 2.14576721191e-06 > 2 3.09944152832e-06 > 3 1.00135803223e-05 > 4 0.000104904174805 > 5 0.00098991394043 > 6 0.00413608551025 > 7 0.037693977356 > 8 0.362598896027 > > Looks pretty linear as n gets large. 0.36 seconds (the last line) is a > noticable pause.
Which just proves the point. You had to deliberately set up the situation to make that happen. And it remains just as easy to pinpoint where it is happening, so you can control it. With a garbage collector, you don’t have that control. Even if you try to avoid freeing a single large structure at once, it’s still liable to batch up a lot of small objects to free at once, so the problem can still happen. -- http://mail.python.org/mailman/listinfo/python-list