This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients jeethu, pitrou, rhettinger, serhiy.storchaka, vstinner
Date 2018-01-16.09:30:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516095058.27.0.467229070634.issue32534@psf.upfronthosting.co.za>
In-reply-to
Content
> 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?
History
Date User Action Args
2018-01-16 09:30:58vstinnersetrecipients: + vstinner, rhettinger, pitrou, serhiy.storchaka, jeethu
2018-01-16 09:30:58vstinnersetmessageid: <1516095058.27.0.467229070634.issue32534@psf.upfronthosting.co.za>
2018-01-16 09:30:58vstinnerlinkissue32534 messages
2018-01-16 09:30:58vstinnercreate