Concerns about performance w/Python, Pysco on Pentiums

Michael Hudson mwh at python.net
Fri Mar 7 10:08:16 EST 2003


"Anders J. Munch" <andersjm at dancontrol.dk> writes:

> "Michael Hudson" <mwh at python.net> wrote:
> > CezaryB <cezary at bigfoot.com> writes:
> > 
> > > Tuples are faster then lists. Try this:
> > 
> > You sure about that?
> [...]
> > So simple subscription seems to be ~14% slower for tuples.
> 
> Surprised to see any difference at all.

list[int] is special cased in Python/ceval.c, tuple[int] goes through
a (C) function call.  Both are pretty quick -- 4-and-change million of
either a second -- so this is unlikely to be the bottleneck.

> I would expect what's faster for tuples is creating them, not using them.

Maybe a little, as creating a list involved two allocations.  Timing
anything that so obviously gets the memory hierarchy into play is more
effort than I can be bothered with today.

Cheers,
M.

-- 
  When physicists speak of a TOE, they don't really mean a theory
  of *everything*.  Taken literally, "Everything" covers a lot of
  ground, including biology, art, decoherence and the best way to
  barbecue ribs.                    -- John Baez, sci.physics.research




More information about the Python-list mailing list