What does HackerNews think of Nuitka?

Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.

Language: Python

#12 in Compiler
#38 in Python
That's more of cultural problem in the Python community.

If I provide an end user software to my client written in Python (so not a backend, not a lib...), I will compile it with nuitka (https://github.com/Nuitka/Nuitka) and hide the stack trace (https://www.bitecode.dev/p/why-and-how-to-hide-the-python-st...) to provide a stand alone executable.

This means the users don't have to know it's made with Python or install anything, and it just works.

However, Python is not like Go or Rust, and providing such an installer requires more work, so a huge part of the user base (which have a lot of non professional coders) don't have the skill, time or resources to do it.

And few people make the promotion of it.

I should write an article on that because really, nobody wants to setup python just to use a tool.

Do check out nuitka though, it's has great support for QT, numpy, advanced Python constructs and has a permissive learning curve. You may even get a up to a X4 perf boot.

Not cross compilation though.

There is a startup idea right there.

> Your comment would make sense if Python code could be compiled into x86 or ARM assembly in the first place.

It can actually be compiled (or transpiled) into C code [1] with few limitations, so I can't see why not. It still requires libpython but it should be better than porting the whole interpreter to webassembly.

[1] https://github.com/Nuitka/Nuitka

So the differences:

https://docs.exaloop.io/codon/general/differences

So more limited types (integers) and more type checking and collections have to have one kind of thing in them.

There are other python compilers though, like https://github.com/Nuitka/Nuitka

I wonder really what the advantages/disadvantages of these are?

I've always assumed Python was interpreted until I heard Nuitka [1].

It would be interesting to get a benchmark using CPython vs Nuitka related to this change.

[1] https://github.com/Nuitka/Nuitka

I am always keeping and eye on mypyc, typed_python (llvm Python compiler)[0] and nuitka[1]

I guess that because Python is extremely dynamic, we may never have a full everything-works compiler, but I’m excited about the possibility of this becoming some kind of intermediate step where different parts of the program get compiled when possible.

[0] https://github.com/APrioriInvestments/typed_python [1] https://github.com/Nuitka/Nuitka

There's already an awk-to-C compiler [1], even if it seems to be unmaintained. Python has a couple of them, more or less constrained, including Nuitka [2].

[1] http://awka.sourceforge.net/index.html

[2] https://github.com/Nuitka/Nuitka

Turns out there IS a third party optimizing static compiler for Python:

https://github.com/Nuitka/Nuitka

Also, a 4.4 times boost in case of pypy is enormous. It translates to 4x less energy, 4x less resources to manage, 4x less operational costs, etc

The goal is not to have the fastest implementation, but a fast enough implementation that can be distributed easily.

> I wonder if there is anything that can really be done, outside of something like Cython.

I compile my cli tools with nuitka [0], the resulting binaries take half the time to start. I find the difference quite notable.

[0]: https://github.com/Nuitka/Nuitka

I agree. Most of the issues the parent mentions have been solved with poetry and pipenv.

And if you need "to create a redistributable executable with all your dependencies". You can either use pyinstaller [0] or nuitka [1] both of which are very actively maintained/developed and continually improving.

[0]: https://github.com/pyinstaller/pyinstaller [1]: https://github.com/Nuitka/Nuitka

> mypy makes Python a pleasure to work with again.

This is my experience as well. I love that I have the option to use Python typed and untyped. For little scripts, fiddles, prototypes, etc. it's often convenient to omit type annotations. For solid software that runs in production it's nice to have them.

Another thing that I'm excited about is nuitka [0], a Python to C compiler that allows you to create binaries from Python code. It cut start-up time of a command line tool that I compiled with in half.

[0]: https://github.com/Nuitka/Nuitka

I've been using mypy for a while now and I love it!

I added mypy type annotations to a bunch of old projects and it found some bugs no one was aware of right away.

I love the support I get from mypy within the editor. It works flawlessly on my Linux machine with VSCode. It's quite good at inferring types as well. In most cases it's enough to annotate function parameters and return types. Mypy warns you in case it cannot infer the type for an item.

As of today I add mypy to every project that grows a certain size/importance. I think the optional typing approach is great. I usually start prototyping/modelling with few type annotations and gradually add more of them as the code stabilizes and end up with a fully typed solid piece of software.

I'm also excited about the benefits mypy/typing brings to the table in the area of compiled Python:

Cython is already able to utilize Python type annotations to compile pure Python code:

https://cython.readthedocs.io/en/latest/src/tutorial/pure.ht...

mypyc is another approach:

https://github.com/mypyc/mypyc

Nutika wants to utilize Python type annotations as well:

https://github.com/Nuitka/Nuitka

I guess there are more.

I think sooner or later we will have single file binaries compiled from pure Python that run with much improved performance.

There is another interesting approach on the horizon: https://github.com/Nuitka/Nuitka

Nuitka compiles your Python code to C and leaves you with a single file binary. It also improves performance.

I hope some day some big corp decides to write a decent (open source) Python to C compiler, which makes optional optimizations based on type annotations.

I find this project: https://github.com/Nuitka/Nuitka very interesting, but its written and maintained only by a single person and I never got it to work with any of my apps.