Speeding up parts of an existing Python application with PyPy or Shedskin

I want to improve the speed of working with an existing application, and I'm looking for advice on my possible options. The application is written in Python, uses wxPython and is packaged using py2exe(Windows platforms only). Parts of the application are intensively computed and run too slowly in interpreted Python. I am not familiar with C, so porting code parts is not an option for me.

So, my question basically is that I have a clear idea of ​​my options, as I will explain below, or am I approaching this from the wrong direction?

  • Working with pypy: Today I started experimenting with Pypy - the results are very interesting, because I can run large parts of the code from the pypy interpreter, and I see 5x + speed improvements without changing the code. However, if I understand correctly: (a) Pypy with wxpython support is still working , and (b) I cannot compile it in exe for distribution anyway . So if I’m not mistaken, does this seem bad to me? There is no way to pack, so parts of it are executed with pypy?
  • Convert code to RPython, translate using pypy . So the next option seems to really rewrite parts of the code into a language with limited access to pypy, which seems like a lot of work. But if I do, parts of the code can be compiled into an executable (?), And then I can access the code through ctypes (?).
  • Other limited options Shedskin seems to be a popular alternative here, does it fit my requirements better? Other options seem to be Cpython, Psyco, and Unladen, but all are replaced or no longer supported.
+5
source share
3 answers

PyPy py2exe , , (AFAIK ). , PyPy , , Python, PyPy + stdlib ( , ), . , WxPython PyPy , , , , - pypy-dev, wxpython-dev IRC- , .

RPython . , C dll /ctypes . , RPython , Python , .

: , CPython ( Python, C) Cython ( , Python, C, CPython). . Shedskin, , , , Python. Cython : , Python: .

+6

Cython, ~ 100x python. , . - Cython. , / Numpy , , . :

a = range(1000000)
for i in range(len(a)):
    a[i] += 5

, . :

a = numpy.arange(10000000)
a = a +5

, .

+3

Correction: shedskin can be used to create extension modules, as well as for entire programs.

0
source

All Articles