Yes, but my code was just a contrieved example of the problem, not what I 
am actually doing.

I have a matrix of size (n_dim, n_points). I then want to pass points to 
different distance functions. I therefore pass point_matrix[:, 
current_point] to those distance functions. 

What you are saying is that I could manually inline these distance 
functions and do the explicit unrolling in each of them. That might gain me 
the speed but I lose the modularity and code legibility.

As previously suggested, maybe having immutable types of points with a 
vector of coordinates in each of them is the way to go. 




On Monday, February 2, 2015 at 11:11:17 AM UTC+1, Yuuki Soho wrote:
>
> If you access directly the elements of your arrays it will not allocate 
> memory:
>
>     cum += points[1, j] 
>
> It's often worth adding a loop or reshaping your inputs so you can write 
> your inner code like that 
> and avoid memory allocation.
>

Reply via email to