Skip to content

Instantly share code, notes, and snippets.

@hhatto
Created March 3, 2015 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhatto/604e066cbb6cbe26bc27 to your computer and use it in GitHub Desktop.
Save hhatto/604e066cbb6cbe26bc27 to your computer and use it in GitHub Desktop.
python "not (x in list)" vs "x not in list"
import slowfast
N = 5000000
setup = """\
t = 11
tt = [22, 11, 55]
"""
one = """\
if not (t in tt):
a = 1
"""
two = """\
if t not in tt:
a = 1
"""
slowfast.compare(one, two, setup, number=N)
-----
(slow) 0.259818[sec]
if t not in tt:
a = 1
(fast) 0.258865[sec]
if not (t in tt):
a = 1
1.00 times faster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment