[Tutor] BLAS Implementation on Python

Stefan Behnel stefan_ml at behnel.de
Mon Mar 7 14:28:15 CET 2011

Mahesh Narayanamurthi, 07.03.2011 01:50:
> I am thinking of implementing a BLAS package in pure python. I am wondering
> if this is a good idea. My design goals are:
> [1] Efficient manipulation of Matrices and
>      Vectors using pure python objects and
>      python code.
> [2] Targetted to run on Python3
> [3] Extensive use of defensive programming
>      style
> [4] To serve as a reference design for
>      future High Performance Code in Python
> [5] To serve as a reference material in
>      classroom courses on numerical computing
>      or for hobbyist programmers

First question that comes to my mind: who would use this? The available 
packages are commonly not written in Python, but they are fast, which is 
why they are being used by Python programs. A quick web search brought up 
Tokyo, for example, which wraps BLAS in Cython:


I can see that it would be easier to teach the concepts based on code 
written in Python than based on the existing implementations. Even if there 
likely won't be a real use case, it may still be nice to have a pure Python 
implementation available, if it could serve as a drop-in replacement for 
faster implementations. I.e., you could present the inner workings based on 
the Python code, and then switch to a 'real' implementation for the actual 

However, even if you say "efficient" above (and the algorithms may well be 
efficient), don't expect it to be fast. Python is great for orchestrating 
high performance computations. It's less great for doing them in plain 
Python code.


More information about the Tutor mailing list