Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2022 22:03
What would you like to do?
import timeit
import dis
def test1():
a = [1,2,3,4,5]
a = [9,8,7,6,5]
def test2():
a = [1,2,3,4,5]
a[:] = [9,8,7,6,5]
print("# test1()")
print(timeit.timeit('test1()','from __main__ import test1'))
print("# test2()")
print (timeit.timeit('test2()','from __main__ import test2'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment