How does "for" work?

Aahz Maruch aahz at panix.com
Wed Oct 11 22:32:40 EDT 2000


In article <Pine.SOL.3.96.1001011155912.10163E-100000 at condor.ee.washington.edu>,
Steve Juranich  <sjuranic at condor.ee.washington.edu> wrote:
>
>BTW, I've often wondered anybody has published info about the relative
>speed of complex python objects?  Something like tuples are faster
>than lists are faster than dictionaries (this seems the most obvious
>arrangement).  Can anybody shed any light on this issue for me? Or
>point me to a place that already has this information?

Faster for what?  Each has different properties, and the speed of each
structure depends on the use one is trying to make of it.  I believe
that for speed of read access, tuples and lists are nearly the same
speed; it's just that lists are bigger to handle their mutability.
Tuples cannot be written to, of course, and if you try using them that
way (by recreating them), you'll lose speed quickly.  Dictionaries can
actually be faster than lists for writing, depending on what you're
using for a key and the updating pattern.

Generally, though, the speed of these structures isn't particularly
relevant -- it's the algorithm that manipulates the structure that
matters.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

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

'Gender' isn't a definition, it's a heuristic.  --Aahz



More information about the Python-list mailing list