← Back to context

Comment by sametmax

8 years ago

Nuikta (http://nuitka.net/) already does that and much more:

- it compiles your program and make it stand alone so you can distribute just the exe

- it makes it start faster

- it makes it run faster

- it's fully independant of the system python. Actually your system doesn't even need a python at all

I don't get why it's not used, it's very robust, compatible with 3.6 and on some of my script I get about x4 speed up just on start up alone.

This is different from the package that I've tested (PyInstaller or py2exe).

Is Nuikta compatible with numpy, pickle, etc? I remember that numpy was very problematic with compilers like pypy for a long time.

  • In my experience it's easier and more reliable than PyInstaller or Py2exe to use, and cross plateform (but no cross compilation). It doesn't pack python files with an executable. It translates the Python code to C then compiles it.

    Nuikta supports numpy officially, you can even see it in change logs: http://nuitka.net/posts/nuitka-release-0521.html

    I haven't tried pickle.

  • >This is different from the package that I've tested (PyInstaller or py2exe).

    In an ancestor comment you say:

    > A single file several hundred Megabytes in size.

    Are both points referring to PyInstaller? Asking because I've tried out PyInstaller with small CLI as well as GUI (wxPython) programs, and the resulting EXEs did not reach near that size, IIRC.

    • It was around 150..300 MB if I remember right. Admittedly, I do import a lot of modules. Program startup for me is in the seconds, not milliseconds. I maybe could cut it down 50% or even 80% but then that would cost a few weeks or a few months. Having a quick and robust solution to be implemented in a single week to cut down startup times by that amount would be highly preferable.

      1 reply →

First time I hear about this, and I've looked for alternatives to cxfreeze and its cousins in the past.

Any time I see something like this, I feel like I'm hearing about some homeopathic cancer cure. If Nuitka actually does what it says it does, it's solving a big recurrent problem for the Python community, so why is nobody talking about it?

  • Having followed Nuitka since it started, I can offer my perspective:

    - Before Nuitka, someone already did a "Python->C" compiler along similar lines: translate the Python source code into the C calls that the interpreter will make, eliminating any interpreter overhead and providing C compiler optimization opporunities. That thing sort-of-worked (with v1.5.2 IIRC), but was cumbersome to use and delivered a meager 5% performance improvement for the cases it did support; it was abandoned.

    - Nuitka's plan had the same thing as a starting phase; people told the Nuitka guy that he's wasting his time based on prior experience. When he actually delivered a mostly-robust working version (much more usable than the previous attempts ever were), it indeed delivered only a small performance gain compared to CPython.

    - As a result, it seemed like the community believed both that the whole thing is futile, and that the developer is fighting windmills.

    - a lot of time passes, Nuitka keeps improving with better analysis, translation, compilation, etc - but the community has already cemented its opinion.

    - Nuitka remains a useful magic system known to few.

    I would say that the early Nuitka versions (and the prior attempt) gave it a SEP field that has never been lifted, and short of e.g. DropBox or Facebook adopting it, nothing will lift it either.

    • I think Nuitka is an answer looking for a problem. Usually people move away from Python. If they really need more low level performance, or implement whatever system in Python itself, to solve the problem Nuitka might solve for them.

      That said, it's a wonderful project, I hope more and more people will find it useful for them.

      2 replies →

  • I collect ideas, especially weird and powerful ideas.

    I've learned not to try to talk about it because of that question: "If foo is so great, why isn't everybody using it?"

    It's one of the single greatest frustrations of my life. I don't know. I've never made any progress on it. The best you can say is, "Well, that seems to be human nature." The world is full of "magic beans" and most people seem interested in banging their heads against the wall.

    (Did you know, you can make a 140hp engine that fits in the volume of two stacked pizza boxes and has only one moving part?)

    Anyhow, Nuitka is great, it does do all that.

    And the creator is a freakin' saint for putting up with the way he's been treated by the Python community, is my opinion.

    • Also, you should write a blig about those ideas. Or a place where we can share it, but in a non tin foil way / silver bullet way.

      Eg: after 7 years of having malaria, one tropical disease doctor explained to me that we have been able to cure malaria for years. Generalist doctors usually don't know it because they don't encounter the disease often enough to keep up to date. It's kind of hard pill to swallow given that i always though you had it for life.

      1 reply →

    • Saint is the word given he has be working really seriously at it for 8 years, alone, never complaining, and giving away everything without any recognition.

      1 reply →

  • It's a function of how many people really need that solution. It's high enough that it exists. It's low enough that it's not a thing you do by default or even talk about much. But if you need it and it's compatible with your code - it's there.

    • Actually any sysadmin or scripter wannabe could benefit from nuikta. Twitter even invented pex because of that. Nuikta took some time to become 100% compatible with the latest versions of cPython, but now it's the case so let's all enjoy it.

      2 replies →

Does nuitka build a static executable or do you still need to supply shared libraries with the executable?

  • It builds a static executable if you pass it the --standalone option.

    • No, it doesn't.

        $ echo 'print "Hello world"' > hello.py
        $ nuitka --standalone hello.py 
        $ ldd hello.dist/hello.exe
        	linux-gate.so.1 (0xf7f94000)
        	libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7895000)
        	libpython2.7.so.1.0 => /home/jwilk/hello.dist/libpython2.7.so.1.0 (0xf7508000)
        	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf732f000)
        	/lib/ld-linux.so.2 (0xf7f96000)
        	libz.so.1 => /home/jwilk/hello.dist/libz.so.1 (0xf7310000)
        	libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf72f1000)
        	libutil.so.1 => /home/jwilk/hello.dist/libutil.so.1 (0xf72ed000)
        	libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf71eb000)

      1 reply →