Which is fastest dict or list.index() ?

Kragen Sitaker kragen at pobox.com
Sat Jun 1 15:52:50 EDT 2002


"Shagshag13" <shagshag13 at yahoo.fr> writes:
> My question is which is the best way (best = quickest and memory safe) to
> handle this ?
> Should i subclasse from dict or list ?

I don't think so.

> Should i consider using only one list with toons (and use their index as id)
> ?

Yes, I think that's what you should do.  If you have a lot of toons,
that may be too slow, but unless you can quantitatively estimate the
amount of time list.index will take (and it's too much), try the
simpler method first, and then optimize by adding the dict if
necessary.

> Should i use 2 dicts ?

I don't think so.




More information about the Python-list mailing list