Created originally on Bitbucket by Dodan (Dodan Mihai)
Hello, I would like to propose this fix for the list.sort() issue (#2410).
I took Carl's advice and I have modified the SimpleSort class in listobject.py. Its lt function now has a jitdriver to solve the problem that the rpython code was not jitted, and, as Carl suspected, it had to exit the jitted code for every comparison to determine the type of objects being compared.
Performance wise, as you can see in the picture below, the fix alleviates the problem completely. The tests have been done on smaller lists of tuples but ran multiple times, and with a warmup phase. The fix is also preserved when running the original code:
- 4.54807 for list.sort(key) on a 2000000 list of objects (no warmup)
- 4.20298 for the fixed list.sort() on a 2000000 list of objects (no warmup)
Also all the both of the list tests (test_listobject.py and test_liststrategy.py) pass entirely.