Which is faster? (if not b in m) or (if m.count(b) > 0)

Peter Hansen peter at engcorp.com
Fri Feb 17 14:40:46 EST 2006


Farel wrote:
> Tim, Are you saying that:
>      not (b in m)
> is faster than:
>     b not in m
> ????

As Bruno tried to tell you, and I quote:

"""
Why don't you try by yourself ?
hint :
from timeit import Timer
help(Timer)
"""

Asking "which is faster" in comp.lang.python is the least efficient way 
of getting an answer, for everyone who reads the newsgroup, everyone who 
tries to help and, most importantly, for yourself.

-Peter




More information about the Python-list mailing list