This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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