New submission from Jeethu Rao <jee...@jeethurao.com>:

I've noticed that replacing the for loop in the ins1 function in listobject.c 
with a memmove when the number of pointers to move is greater than 16 seems to 
speed up list.insert by about 3 to 4x on a contrived benchmark.

# Before
jeethu@dev:cpython  (master)$ ./python -m timeit -s "l = []" "for _ in 
range(100): l.insert(0, None)"
200 loops, best of 5: 3.07 msec per loop

#After
jeethu@dev:cpython  (3.7_list_insert_memmove)$ ./python -m timeit -s "l = []" 
"for _ in range(100): l.insert(0, None)"
500 loops, best of 5: 744 usec per loop

Both builds were configured with --enable-optimizations and --with-lto

----------
components: Interpreter Core
messages: 309806
nosy: jeethu
priority: normal
severity: normal
status: open
title: Speed-up list.insert
type: performance
versions: Python 3.7

_______________________________________
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