I wrote a test code to see how pypy can optimize python code well and run faster. It is a non-in-place quick sort and supposed to run slow enough to make the difference. By simply replacing python
with pypy
, the result is actually slower from 16 seconds to 25 seconds. I searched a bit and found the opt
option, but I can't find a way to apply it to pypy. I'm quite new to python, so help me a bit.
import sys
def sqsort(xxs):
if len(xxs) == 1 or len(xxs) == 0:
return xxs
x = xxs[0]
xs = xxs[1 :]
l = []
g = []
for x2 in xs:
if x2 < x:
l.append(x2)
if x2 >= x:
g.append(x2)
return sqsort(l) + [x] + sqsort(g)
sys.setrecursionlimit(30000)
l = list(reversed(range(15000)))
print(l)
print(sqsort(l))