Hi Jeremy,

Can you share how you are running this function? I tried a few variants, and 
pypy is often faster than CPython on my attempts, so the rest of your code is 
necessary to find out what's wrong.

Cheers,

CF 

On September 18, 2024 5:43:06 AM GMT+02:00, Jeremy Brown 
<[email protected]> wrote:
>Hello,
>
>I'm working on a project that involves benchmarking CPython and PyPy
>across a few benchmarks I've devised, but PyPy is so much slower than
>CPython I feel I must have made some sort of mistake. One major
>headscratcher is that CPython runtimes hold stable while PyPy appears
>to get worse as the benchmark progresses.
>
>I've included an excerpt of the benchmark below that shows the issue,
>if I can attach files that won't be lost I can attach a full copy; I
>don't believe the string operations are the issue because the
>micro-tuning tips suggest the JIT reduces concatenation overhead in
>scenarios like these (if I'm reading the page right). [1]
>
>def recurse(num):
>    if num >= 1000:
>        return "M" + recurse(num - 1000)
>
>    elif num >= 900:
>        return "CM" + recurse(num - 900)
>
>    elif num >= 500:
>        return "D" + recurse(num - 500)
>
>    elif num >= 400:
>        return "CD" + recurse(num - 400)
>
>    elif num >= 100:
>        return "C" + recurse(num - 100)
>
>    elif num >= 90:
>        return "XC" + recurse(num - 90)
>
>    elif num >= 50:
>        return "L" + recurse(num - 50)
>
>    elif num >= 40:
>        return "XL" + recurse(num - 40)
>
>    elif num >= 10:
>        return "X" + recurse(num - 10)
>
>    elif num >= 9:
>        return "IX" + recurse(num - 9)
>
>    elif num >= 5:
>        return "V" + recurse(num - 5)
>
>    elif num >= 4:
>        return "IV" + recurse(num - 4)
>
>    elif num >= 1:
>        return "I" + recurse(num - 1)
>
>    else:
>        return ""
>
>-Jeremy
>
>[1]: https://pypy.org/performance.html#micro-tuning-tips
>_______________________________________________
>pypy-dev mailing list -- [email protected]
>To unsubscribe send an email to [email protected]
>https://mail.python.org/mailman3/lists/pypy-dev.python.org/
>Member address: [email protected]
_______________________________________________
pypy-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pypy-dev.python.org/
Member address: [email protected]

Reply via email to