STINNER Victor <victor.stin...@gmail.com> added the comment:

> jeethu@dev:cpython  (3.7_list_insert_memmove)$ ./python -m timeit -s "l = []" 
> "for _ in range(100): l.insert(0, None)"

Please don't use timeit, but perf timeit to run such *microbenchmark* (time 
smaller than 1 ms).

Your benchmark measures also the performance of the loop, it might be 
significant in such short loop (100 items). You may try to unroll the loop 
manually, and truncate the list:

vstinner@apu$ python3 -c 'print("l.insert(None); " * 3 + "l.clear();")'
l.insert(None); l.insert(None); l.insert(None); l.clear();

Example:

python3 -m perf timeit -s 'l=[]' $(python3 -c 'print("l.insert(0, None); " * 
100 + "l.clear();")') --duplicate 100


Jeethu Rao: Are you using CPU isolation? What is your OS?

----------
nosy: +vstinner

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32534>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to