Less obtuse list.append() benchmark

This commit is contained in:
K. Lange 2022-06-04 12:13:38 +09:00
parent 75e0ec9e54
commit cd25ada161
2 changed files with 12 additions and 14 deletions

View File

@ -1,11 +1,10 @@
from timeit import timeit
let l = []
let add = l.append
let pop = l.pop
if True:
let l = []
def func():
add(1)
pop()
def func():
l.append(1)
l.pop()
print(min(timeit(func,number=100000) for x in range(10)), "list append")
print(min(timeit(func,number=100000) for x in range(10)), "list append")

View File

@ -1,11 +1,10 @@
from fasttimer import timeit
l = []
add = l.append
pop = l.pop
if True:
l = []
def func():
add(1)
pop()
def func():
l.append(1)
l.pop()
print(min(timeit(func,number=100000) for x in range(10)), "list append")
print(min(timeit(func,number=100000) for x in range(10)), "list append")