Skip to content

Instantly share code, notes, and snippets.

@dschniepp
Created March 14, 2022 22:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
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'))
dis.dis(test1)
print("# test2()")
print (timeit.timeit('test2()','from __main__ import test2'))
dis.dis(test2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment