[Tutor] BLAS Implementation on Python
alan.gauld at btinternet.com
Tue Mar 8 09:51:18 CET 2011
"Knacktus" <knacktus at googlemail.com> wrote
> He doesn't have to write it, as it is very obvious, that no Python
> code on earth (even written by Guido himself ;-)) stands a chance
> compared to Fortran or C. Look at this:
There is one big proviso. The C or Fortran needs to be well written
in the first place. It's quite possible to write code in Python that
outperforms badly written C. And it is quite easy to write bad C!
This is similar to the arguments in the 1960's/70's when languages
like C first appeared. The assembler programmers all said you'd
never replace assembler with C because assembler was an
order of magnitude faster (and smaller because size mattered then!).
But that was only true of well optimised assembler. Nowadays
speed is hardly ever used as a reason for using assembler.
Now the case between interpreted and compiled languages is
slightly different, but as python compilers emerge the gap will
continue to narrow. Will Python ever challenge C/assembler?
Probably not in the low level domain but where we are talking
about implementing complex algorithms it may well do.
But its a long way off just now and if you need speed
selectively rewriting in C is still the best bet. The skill is
in selecting the bits to optimise. But a pure Python
implementation will benefit from any improvements
that are made going forward without significant rework.
Author of the Learn to Program web site
More information about the Tutor