Message 309806 - Python tracker

Message309806

Author jeethu
Recipients jeethu
Date 2018-01-11.13:52:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515678734.85.0.467229070634.issue32534@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-01-11 13:52:14jeethusetrecipients: + jeethu
2018-01-11 13:52:14jeethusetmessageid: <1515678734.85.0.467229070634.issue32534@psf.upfronthosting.co.za>
2018-01-11 13:52:14jeethulinkissue32534 messages
2018-01-11 13:52:14jeethucreate