Live data from Hacker News

Nuitka: An extremely compatible Python compiler

nuitka.net

61–70 of 88 posts

Re: Nuitka: An extremely compatible Python compiler

#61

This project is super impressive. It makes me wonder why there's not a similarly mature JavaScript AOT compiler implementation for use in game development or other places where you want performance better than a VM and you're not allowed to JIT. A small recommendation for these release pages would be to link to the tag in whatever source host you're using! I just want to see the code.

You'd be stuck with float numerics everywhere because there's no fallback to recompile if an attempt to use integer fails.

compile both, dispatch dynamically in runtime.

Re: Nuitka: An extremely compatible Python compiler

#62
post #58
post #56

Earlier quoted context omitted.

https://pybenchmarks.org/u64q/benchmark.php?test=all&lang=nu... "Python Interpreters Benchmarks"

Thanks for the link. Don't know if you are affiliated but there is a lot of link rot going on there with external links.

Sorry, not mine.

https://github.com/dundee/pybenchmarks/issues

Re: Nuitka: An extremely compatible Python compiler

#63

Earlier quoted context omitted.

The best feature of nuitka, and its main goal, is not speed gain. That's the cherry on top. The main goal is getting a standalone executable that works with c extensions.

that's correct, nuitka is to package python into one single executable, it's an 'installer' per se.

Not an installer no. The installer part is not provided, the result is an executable that works out of the box. The installer would then take that and put it somewhere, but you don't need to. It can even work from a USB key.

Re: Nuitka: An extremely compatible Python compiler

#64

Earlier quoted context omitted.

nuitka takes your python code and all its deps, turns it to c code, and compiles that into a standalone executable that is both faster and doesn't need a separate python vm to be installed.

Expect it does require libpython and at least on Ubuntu 20.04 it links against the dev version of the library. So not only can you not run the resulting binary on any random Ubuntu 20.04 you also need to install same version of the python and the "-dev" version. I did try this. With the "stock" python3 (3.8.something) I couldn't get nuitka to compile my code (or the example from the docs). With python3.9 I could star…

If you pass the proper option, it will compile everything, including libpython, resulting in a stand alone executable.

The only dep would be libc, and if you compile against an old version, it should be forward compatible.

Re: Nuitka: An extremely compatible Python compiler

#65
post #47

Earlier quoted context omitted.

Expect it does require libpython and at least on Ubuntu 20.04 it links against the dev version of the library. So not only can you not run the resulting binary on any random Ubuntu 20.04 you also need to install same version of the python and the "-dev" version. I did try this. With the "stock" python3 (3.8.something) I couldn't get nuitka to compile my code (or the example from the docs). With python3.9 I could star…

it has an option to build with libpython. so your comment is incorrect.

I guess there is a good reason for it to not be default behavior

Re: Nuitka: An extremely compatible Python compiler

#66
post #8

Wow, this got my attention. I use Python for web application development. A 2-3x speedup would be very interesting for higher-load deployments.

The best feature of nuitka, and its main goal, is not speed gain. That's the cherry on top. The main goal is getting a standalone executable that works with c extensions.

Does it also package the extensions?

Re: Nuitka: An extremely compatible Python compiler

#67

It would be neat if the big companies like Dropbox, Instagram, Google, Oracle, Shopify, Stripe, whatnot building better Python/JavaScript/Ruby implementations would start building program analysis libraries for Python/JavaScript/Ruby so that more implementations could get this for free. For example, the homepage of Nuitka says they only just added support for constant folding and propagation. That's such low hanging…

An issue, though not an unsolvable one, is that you probably need a standardized representation of the AST to write these optimization passes against; it is not uncommon for compiler writers to disagree on what representation is the best for what purpose. Then there is the question of optimizations that are (typically) easier/possible only at the code-generation phase. All of this is solvable of course, but there nee…

LLVM IR?

Re: Nuitka: An extremely compatible Python compiler

#69
post #35

Earlier quoted context omitted.

What sort of web applications do you work on where Python interpreter speed is the limiting factor? Usually, those applications are constrained by network throughput and context switches and page faults.

This argument is so tiring. That's part of why websites are so slow despite having insane hardware at their disposal. At my company, for a web app we run in production, we strive to get every response out of our infrastructure in under a millisecond, everything above that except for a few select endpoints is considered as a bug. By using sensible technology choices, it's not even that hard to do. A RDMS like postgres…

Most websites today are slow due to loading megabytes of javascript, trackers from a dozen domains, css frameworks, and large images.

Re: Nuitka: An extremely compatible Python compiler

#70

Earlier quoted context omitted.

"Can compile Javascript sources to executables with no external dependency"

Which probably works by stapling bytecode to a precompiled interpreter. A tried and true strategy, but not necessarily what people want when asking for AOT compilation.

It's only a few steps away from what Graal/Truffle do: unroll the interpreter loop over the bytecode, then keep re-running dead code elimination and inlining passes - you end up with something very close to optimized native output.
Post reply on HN