Dictionary vs if-elif?

Aahz Maruch aahz at netcom.com
Tue Jun 20 22:19:11 EDT 2000


In article <rg10ls89rd67ufpp48s2pr8j78q657kbdm at 4ax.com>,
Ralf Canis  <ralf at silicon.org> wrote:
>
>Don't know if this is really better but how about:
>
>bogusCodes = ( '1.', '31', '90', 'AZ' ...... )
>...
>if item in bogusCodes:
>  do something useful

That's a Bad Idea.  It's a linear search instead of a hash.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

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

"This is Usenet.  We're all masturbating in public places."  -DH



More information about the Python-list mailing list