top | item 41467486

(no title)

hellohello2 | 1 year ago

What is your use case? I struggle to see how ~4x faster Python has much value but I guess the effective speedup/value of that speedup depends on what you are doing.

EDIT: By that I meant, if you are trying to make something fast, wouldn't it make more sense to rewrite the critical path in a faster language rather than trying to improve Python's speed?

discuss

order

LegionMammal978|1 year ago

IME, PyPy can get up to 100x faster for many use cases. Most of my Python scripts have a lot of pure-Python code manipulating ints, strs, dicts, etc. (wrangling data between formats and/or doing basic processing), and switching from CPython to PyPy often turns the execution time from minutes into seconds.

You'll likely get much less of a speedup if your program is already optimized around CPython's slowness, e.g., by calling out to libraries like numpy as much as possible. But PyPy lets my simple scripts punch above their weight without any extra circumlocutions.

binary132|1 year ago

OP is about a Python app that had a costly inner loop. This could perhaps be improved by switching to a JIT compiled implementation of Python like Pypy, but there are drawbacks and potential dealbreakers too.

v3ss0n|1 year ago

Most of the case 20x faster not just 4x. 4x faster is mostly bad cases. Worst cases ( a bit slower than python) c-extension for these needing cext, use python.

Why rewrite when you can achieve same without any code changes? PyPy performance rivals golang .

In OP Case this could increase performance by 20x easily.

l33t7332273|1 year ago

Some things aren’t feasible to use another language for, but I see your point.

My use case is MILP optimization. Constructing the model representation(the step necessary before calling some optimizer binary) is very slow in CPython, and Pypy makes development much less painful, since you often need to construct many models to get it right.

hellohello2|1 year ago

Thanks, this is really interesting. How big of a speed up have you been observing?