list vs. dict

Jeff Shannon jeff at
Thu Feb 28 21:04:24 CET 2002

dsavitsk wrote:

> "Max M" <maxm at> wrote in message news:3C7CFAF8.1080108 at
> > btw: if you really want to store it in a list you can get dict-like
> > behaviour with list speed like this:
> is this a python idiom that people often use? cause i've not seen it before,
> but it is really clever.

No, it's not something that people often use.  Generally, if you want dict-like
behavior, you just use a dict.  The times that it's worth the effort to fake the
behavior with something else, are pretty unusual.  The speed difference between
lists and dicts isn't all that significant, anyhow, and which one has the
advantage depends on how you're using it.  Python dicts are pretty amazingly
nifty, really; there's no reason to be shy about using them.

Jeff Shannon
Credit International

More information about the Python-list mailing list