Hacker News new | ask | show | jobs
by TheAlchemist 804 days ago
I would say, there is no such thing as fast Python code. It's not the purpose of the language.

You make want to take a look at Mojo: https://www.modular.com/max/mojo

It's not really there yet, but the promise is to "combine the usability of Python with the performance of C"

2 comments

Numba and Cython can speed up Python code dramatically. Also, Python takes advantage of a lot of libraries which are C/C++/Rust at the their core.

In many cases, it is possible to get Python code to within 2-10x of C using numpy/numba/cython... but with 10% of the lines of code. In many cases, this is an acceptable trade.

> I would say, there is no such thing as fast Python code. It's not the purpose of the language.

It's not the purpose of the language but (business) needs don't generally care about such things. Sometimes you can't rewrite in rust for a variety of reasons and then it can pay off to know what's faster rather than slower in CPython.

But you can just have your python code calling a C/Rust library binding, which has been the acceptable answer for "how to make this python code faster?" since the beginning of time.