Live data from Hacker News

Nuitka — A Python Compiler

kayhayen24x7.homelinux.org

1–10 of 34 posts

Re: Nuitka — A Python Compiler

#2
The licence (GPLv3) limits its use a bit - at least for people who prefer other licences like BSD or MIT.

The generated C++ source contains the following comment:

// This code is in part copyright Kay Hayen, license GPLv3. This has the consequence that // your must either obtain a commercial license or also publish your original source code // under the same license unless you don't distribute this source or its binary.

Re: Nuitka — A Python Compiler

#3
post #2

The licence (GPLv3) limits its use a bit - at least for people who prefer other licences like BSD or MIT. The generated C++ source contains the following comment: // This code is in part copyright Kay Hayen, license GPLv3. This has the consequence that // your must either obtain a commercial license or also publish your original source code // under the same license unless you don't distribute this source or its bina…

I'm confused by this. I thought the license used by a compiler had no effect on the licenses that could be used for programs compiled by it. If the author of Nuitka is claiming that software compiled by Nuitka is in fact a derivative work of Nuitka, that is indeed very problematic.

Re: Nuitka — A Python Compiler

#4
Personally I have more faith in JITs for dynamic languages such as Python. It just seems a more natural match. That said, I'm sure there are many Python programs out there that are essencially static.

Did anybody else notice the large number of compilers/interpreters/tools built for python in comparison to many other languages out there? I think it might partly be the advantage of having an easy to parse language with well defined semantics.

Re: Nuitka — A Python Compiler

#5
post #2

The licence (GPLv3) limits its use a bit - at least for people who prefer other licences like BSD or MIT. The generated C++ source contains the following comment: // This code is in part copyright Kay Hayen, license GPLv3. This has the consequence that // your must either obtain a commercial license or also publish your original source code // under the same license unless you don't distribute this source or its bina…

I'm confused by this. I thought the license used by a compiler had no effect on the licenses that could be used for programs compiled by it. If the author of Nuitka is claiming that software compiled by Nuitka is in fact a derivative work of Nuitka, that is indeed very problematic.

That was my immediate assumption too, but part of the compiler's output is going to be some kind of a runtime library. If that itself is GPL 3 and the code generated by the compiler statically links to it, then I'm pretty sure a case could be made that the compiler's output is a derivitive work. Kind of sneaky and non intuitive, though.

This is all way out of my area of expertise, so take it with a grain of salt.

Re: Nuitka — A Python Compiler

#7
I was developing a compiler called unPython for a while but I have not yet released it openly. Plan to do so "soon". It is a compiler for annotated subset of Python (particularly NumPy, rest of it being very slow or not supported) to a C++ Python module. Will post here once I release it.

Re: Nuitka — A Python Compiler

#8
Here's a simple test for the curious. It's not a benchmark.

  import math
  num_primes = 0
  for i in xrange(2, 500000):
    if all(i % j for j in xrange(2, int(math.sqrt(i)) + 1)):
      num_primes += 1
  print num_primes
Here's the code above translated to C++ by Nuitka: http://pastebin.com/41ueyTEB

  # CPython 2.6.6
  $ time python hello.py 
  41538
  real	0m6.377s
  user	0m6.350s
  sys	0m0.020s

  # Nuitka & g++-4.5
  $ time ./hello.exe
  41538
  real	0m4.573s
  user	0m4.270s
  sys	0m0.300s

Re: Nuitka — A Python Compiler

#9
I sometimes see people ask about translating a language like Python to Common Lisp (or another language that can be compiled) as a kind of optimization.

The problem, in general, isn't that Python and languages like it don't have a compiler, it's that the semantics of the language are hostile to good performance by traditional means of compilation. To do what the programmer requests requires doing things at runtime that are hard to make fast. That's why things like tracing JITs are being used for things like JavaScript.

The speedup you get from actually compiling Python programs is because the CPython interpreter is pretty awful, not because compilation is a magic solution to performance problems. The IronPython guy gave a nice explanation of this at OOPSLA 2007's Dynamic Languages Symposium - maybe things have changed in CPython since then.

Re: Nuitka — A Python Compiler

#10

I sometimes see people ask about translating a language like Python to Common Lisp (or another language that can be compiled) as a kind of optimization. The problem, in general, isn't that Python and languages like it don't have a compiler, it's that the semantics of the language are hostile to good performance by traditional means of compilation. To do what the programmer requests requires doing things at runtime th…

Compilation also helps distribution, though. Distributing a single compiled binary for a particular platform is a lot easier than telling people they need to have some particular version of Python and libraries installed.
Post reply on HN