How to make this faster
jarausch at igpm.rwth-aachen.de
Fri Jul 5 16:48:17 CEST 2013
On Fri, 05 Jul 2013 12:02:21 +0000, Steven D'Aprano wrote:
> On Fri, 05 Jul 2013 10:53:35 +0000, Helmut Jarausch wrote:
>> Since I don't do any numerical stuff with the arrays, Numpy doesn't seem
>> to be a good choice. I think this is an argument to add real arrays to
> Guido's time machine strikes again:
> import array
> By the way, I'm not exactly sure how you go from "I don't do numerical
> calculations on numpy arrays" to "therefore Python should have arrays".
I should have been more clear. I meant multi-dimensional arrays (2D, at least)
Numpy is fine if I do math with matrices (without loops in python).
Given that I don't like to use the old FORTRAN way (when "dynamic" arrays are passed to
functions) of indexing a 2-d array I would need a MACRO or an INLINED function in Python
or something like a META-compiler phase transforming
def access2d(v,i,j,dim1) : # doesn't work on the l.h.s.
access2d(v,i,j,dim1) = 7 # at compile time, please
v[i*dim1+j]= 7 # this, by itself, is considered ugly (the FORTRAN way)
Thanks for the discussion,
More information about the Python-list