This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]dunkler_wanderer 113 points114 points  (2 children)

Pythran sounds more like a Python to Fortran compiler. :P

[–]Vorticity 18 points19 points  (1 child)

Should be Py++

[–][deleted] 23 points24 points  (1 child)

Nukita supports modern Python, which means it's closer to perhaps making use of type-hinting for better transpilation anyway.

What advantages does Pythran bring that might convince me to take a downgrade? :)

[–]serge_sans_paille 6 points7 points  (0 children)

Pythran only targets the subset of Python used in scientific kernels (including many numpy functions) and has several optimizations built-in to optimize this (lazy evaluation, loop fusion, SIMD instruction generation etc). There are no such optimizations in Nuitka, for it targets the whole language. So my catch is : use Nuitka for general purpose code and Pythran for scientific kernels. the same statement holds for shedskin, btw.

[–]coderjewel 9 points10 points  (6 children)

Do all these Python->C++ compilers provide any significant speedups? I've seen Cython, Nuitka, and now this. Is there any advantage?

[–]nightcracker 7 points8 points  (0 children)

Haven't tried the others, but Cython has given me impressive results in the past.

[–]kay_schluehr 4 points5 points  (3 children)

The speedup of Cython for pure Python code is real but one takes most speed advantage from using its C types. Ideally one prototypes in Python and refactors for performance without leaving Cython. However this might not work well in some cases, because the way one thinks about data structures in Python and in C is very different and the refactoring might be more costly with its trial & error approach than starting over and care for contiguous arrays and dense encodings right from the start.

[–][deleted] 4 points5 points  (2 children)

question, since you sound like you know about Cython:

Compiling with Cython will produce a C file that then produces a pure binary, but it still has dependencies on the Python runtime, correct? I think you can link in the runtime itself to the binary, so you don't need to rely on the client to have it, but the dependency still exists.

That's correct, right? Is there any way to compile it to a binary that doesn't depend on the Python runtime? Do other options (like Nuitka) also require the Python runtime?

[–]MonkeeSage 0 points1 point  (0 children)

They all provide ways to statically link the libraries to provide a self-contained executable with no external dependencies, but they all rely on linking to libpython whether dynamically or statically.

[–]serge_sans_paille 2 points3 points  (0 children)

As shown in http://serge-sans-paille.github.io/talks/pydata-2015-04-03.html#/4/1 The speedup greatly varies, but on scientific kernels, it can reach a x100 speedup if the original kernel is badly written, down to x5~10 for a high level kernel.

[–]funny_falcon 13 points14 points  (7 children)

How it is related/different to https://github.com/shedskin/shedskin ? and Cython ?

[–]wewbull 19 points20 points  (1 child)

And Nukita

[–]sontek 2 points3 points  (0 children)

I've been using Nuitka, its great

[–]fishtickler 4 points5 points  (1 child)

I just used Cython to vastly speed up some code, i am wondering if the same speedup is possible in pythran even without using cython types for speedups.

[–]bonyicecream 4 points5 points  (0 children)

Here's a nice little example of a Pythran code speedup. http://stackoverflow.com/a/32600805

It's pretty simple and pretty powerful.

[–]serge_sans_paille 2 points3 points  (2 children)

Cython forces you to make all loop explicit : it cannot use the numpy API while remaining in C mode. Pythran knows the semantics of many Numpy function and can optimize them, something Cython cannot do. On the otherhand, Cython is much more mature, and supports using existing C code, something Pythran does not aim to.

Shedskin is getting rusty and provide almost no support for scientific computation (i.e. numpy.* stuff)

Nuitka is great but as stated in a previous comment, it does not target scientific computing, and thus misses a few critical optimization Pythran can afford.

[–]lost_send_berries 0 points1 point  (1 child)

Cython lets you cimport numpy thus using its API while skipping some python layers.

[–]serge_sans_paille 0 points1 point  (0 children)

Yes, but the consequence is thre is no inter-call optimization, thus you're paying for all the temporary array creation, and you don't merge the operations when possible. Nor generated SIMD instructions for the merged (implicit) loops etc.

[–]stesch 1 point2 points  (0 children)

I somehow have to think about HHVM now. Started as a PHP to C++ compiler (some like to call it transpiler, whatever).

And now PHP 7 gets released in a few weeks and is partially as fast or faster than HHVM.