The timeit code disables the garbage collector while running. I ran the tests on my system after adding the following lines to t1() and t2(). del base gc.collect()
Original timetest.py: Using proxy 100 loops, best of 3: 4.45 msec per loop Call to dummy proxy 100 loops, best of 3: 2.24 msec per loop Without proxy call 100 loops, best of 3: 3.01 msec per loop With garbage collection: Using proxy 100 loops, best of 3: 5.17 msec per loop Call to dummy proxy 100 loops, best of 3: 4.27 msec per loop Without proxy call 100 loops, best of 3: 3.99 msec per loop The overhead of weakref still doesn't outweigh the overhead of cyclic garbage collection, but they narrow the gap. I also saw a bit of noise while running this benchmark. Different runs were giving me varying times. Large enough to see about 20% discrepencies. -- http://mail.python.org/mailman/listinfo/python-list