Jean-Francois Moulin wrote:
> What I have is a big 3d L array for which I need to increment a single
> element by one at each call

Something like this?


def MyFun(arr, i, j, k):
     arr[i,j,k] += 1


If so, the you might as well keep it in python.

That little operation must be inside a some loop of some sort. The goal 
is to move the whole loop into Cython. Then you can pass in the array, 
and cython can convert your code into nice, fast C-type indexing.


 > So, for now I
> can separate more sophisticated operations and perform them later once
> the array is finalized... I can thus build my array as a huge list of
> lists

Why do you need to build it as lists? Usually you only need to do this 
if you don't know how big it's going to be when you start.

> Or is
> it worth (possible?) to use the array.array object of python.

I don't think that buys you anything over numpy arrays, and you lose a lot!

Perhaps a bit more description of your problem, and/or a stripped down 
pure-python version for us to comment on. I suspect that you could 
improve your performance a lot just by using numpy optimally (which 
means a post to the numpy list may be in order)

NOTE: when faced with issues like this, you'll get the best results from 
a list if you post your problem, rather than a solution you are trying 
-- If can can pose your problem succinctly and clearly, the odds are 
good someone may have a better solution that the one you've come up with!


-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[email protected]
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to