logoalt Hacker News

OptionOfT10/01/20243 repliesview on HN

Most of these native libraries' output isn't 1-1 mappable to Python. Based on the data you need to write native data wrappers, or worse, marshal the data into managed memory. The overhead can be high.

It gets worse because Python doesn't expose you to memory management. This initially is an advantage, but later on causes bloat.

Python is an incredibly easy interface over these native libraries, but has a lot of runtime costs.


Replies

nicce10/01/2024

> Python is an incredibly easy interface over these native libraries, but has a lot of runtime costs.

It also means that many people use Python while they don't understand that what part of the code is actually fast. They mix Python code with wrappers to native libraries, and sometimes the Python code slows down the overall work substantially and people don't know that fault is there. E.g use Python Maths with the mix of Numpy math bindings, while they can do it with Numpy alone.

__coaxialcabal10/01/2024

Have you had any success using LLMs to rewrite Python to rust?

show 1 reply
pjmlp10/01/2024

Yet another reason to use native compiled languages with bindings to the same C and C++ libraries.

If using C++20 onwards, then it is relatively easy to have similar high level abstractions, one just needs to let go of Cisms that many insist in using.

Here Rust has clearly an advantage that it doesn't allow for copy-paste of C like code.

Naturally D and Swift with their safety and C++ interop, would be an option as well.