#/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
def test_set():
l = range(100)
s = set(range(100))
for i in l:
if i in s:
pass
return
def test_list():
l1 = range(100)
l2 = range(100)
for i in l1:
if i in l2:
pass
return
if __name__ == "__main__":
t1 = timeit.Timer("test_set()", "from __main__ import test_set")
print t1.timeit()
t2 = timeit.Timer("test_list()", "from __main__ import test_list")
print t2.timeit()
# -*- coding: utf-8 -*-
import timeit
def test_set():
l = range(100)
s = set(range(100))
for i in l:
if i in s:
pass
return
def test_list():
l1 = range(100)
l2 = range(100)
for i in l1:
if i in l2:
pass
return
if __name__ == "__main__":
t1 = timeit.Timer("test_set()", "from __main__ import test_set")
print t1.timeit()
t2 = timeit.Timer("test_list()", "from __main__ import test_list")
print t2.timeit()