Tremendous slowdown due to garbage collection

andreas.eisele at gmail.com andreas.eisele at gmail.com
Sat Apr 12 12:53:13 EDT 2008


Sorry, I have to correct my last posting again:

> > Disabling the gc may not be a good idea in a real application; I suggest
> > you to play with the gc.set_threshold function and set larger values, at
> > least while building the dictionary. (700, 1000, 10) seems to yield good
> > results.
> > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]'
>
> 10 loops, best of 3: 658 msec per loop
>

Looks nice, but it is pointless, as timeit disables gc by default,
and the set_threshold hence has no effect. In order to see the real
effect of this, I need to say

> python2.5 -m timeit 'gc.enable();gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]'

which gives me

10 loops, best of 3: 1.26 sec per loop

Still a factor of more than 10 faster than the default settings.

> which made me suggest to use these as defaults, but then
> Martin v. Löwis wrote that
>
> > No, the defaults are correct for typical applications.

Complex topic...



More information about the Python-list mailing list