which one is more efficient

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sat Feb 9 11:08:15 CET 2008


Michael Spencer:
> # perhaps faster
> $ python -mtimeit -s"t='D'" "if t in 'DE': pass"
> 1000000 loops, best of 3: 0.204 usec per loop

That may be faster indeed, but it gives true if t is "DE" too, and
that may be bad.
The new string search done by Effbot is really good :-)

Bye,
bearophile



More information about the Python-list mailing list