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 -- pypy-dev@python.org
To unsubscribe send an email to pypy-dev-le...@python.org
https://mail.python.org/mailman3/lists/pypy-dev.python.org/
Member address: arch...@mail-archive.com

Reply via email to