Interesting speed benchmark

Aahz Maruch aahz at panix.com
Wed Jun 6 02:04:16 EDT 2001


In article <3B1D6FED.4070506 at nospam.yahoo.com>,
Mahesh Padmanabhan  <micronospampad at nospam.yahoo.com> wrote:
>
>class ObjectTest:
>         pass
>
>for i in xrange(1000):
>     root=ObjectTest()
>     for j in xrange(10000):
>         root.next=ObjectTest()
>         root=root.next

My guess is that this represents a pathological case for Python's memory
management system.  Each time through the outer loop after the first,
Python has to walk the chain of 10K objects, deallocating them
one-by-one.  I'd be curious what happens if you simply create/destroy
that many objects without creating a linear chain of them.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list