Basic Python Questions - Oct. 31, 2013

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Nov 3 02:43:13 EST 2013


On Sun, 03 Nov 2013 01:02:24 -0500, E.D.G. wrote:

[...]
> Since Perl has a calculation speed
> limit that is probably not easy to get around, before too long another
> language will be selected for initially doing certain things such as
> performing calculations and plotting charts. And the existing Perl code
> might then be gradually translated into that new language.

The nice things about Python are that it makes a great glue language for 
putting together components written in low-level languages like C and 
Fortran, and that there is a rich ecosystem of products for speeding it
up in various ways. So when you hit the speed limits of pure Python, you
have lots of options. In no particular order:


* try using another Python compiler: PyPy is probably the most 
  mature of the stand-alone optimizing compilers, and you can 
  expect to double the speed of "typical" Python code, but 
  there are others;

* use numpy and scipy for vectorized mathematical routines;

* re-write critical code as C or Fortran libraries;

* use Pyrex (possibly unmaintained now) or Cython to write
  C extensions in a Python-like language;

* use Psyco or Numba (JIT specialising compilers for Python);

* use Theano (optimizing computer algebra system compiler);

* use ctypes to call C functions directly;

* use other products like Boost, Weave, and more.


See, for example:

http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/

http://technicaldiscovery.blogspot.com.au/2011/06/speeding-up-python-numpy-cython-and.html



-- 
Steven



More information about the Python-list mailing list