Basic Python Questions - Oct. 31, 2013

rusi rustompmody at gmail.com
Sun Nov 3 19:28:42 CET 2013


On Sunday, November 3, 2013 1:13:13 PM UTC+5:30, Steven D'Aprano wrote:
> 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.

Yes python is really state-of-art in this respect:
Every language will have some area where it sucks.
Allowing for a hatch where one could jump out is helpful.
Python allows more such hatches than probably any other language (that I know)

https://mail.python.org/pipermail/python-list/2012-August/628090.html
is a (non exhaustive) list I had made some time.

On the other hand if you know you are going to be escaping out often,
you may want to consider whether the 'escapee' should be your base
rather than python.

Which means take something like the pairwise function and code it up in python and julia -- its hardly 10 lines of code.  And see what comparative performance you get. 



More information about the Python-list mailing list