In [1]:
%%timeit
l = [1, 2]
l.extend([3, 4])
In [2]:
%%timeit
l = [1, 2]
l += [3, 4]
In [3]:
def extend_list(l):
l.extend([3, 4])
def extend_list_with_add(l):
l += [3, 4]
In [4]:
import dis
dis.dis(extend_list)
In [5]:
dis.dis(extend_list_with_add)