Ticket #178 (new enhancement)

Opened 4 years ago

Last modified 4 years ago

Efficient slices in buffers

Reported by: dagss Owned by: somebody
Priority: major Milestone: wishlist
Component: Code Generation Keywords: numerics
Cc:

Description (last modified by dagss) (diff)

It could be possible to speed up slice operations on acquired buffers; i.e. the buffer protocol exports all information that would be necesarry in order to speed up

cdef object[int, ndim=2] a = ...
cdef object[int, ndim=2] b = a[10:15:-1, 3:7]
cdef object[int, ndim=1] c = a[:, 4]

Change History

Changed 4 years ago by dagss

  • description modified (diff)

Changed 4 years ago by dagss

  • description modified (diff)

Changed 4 years ago by dagss

I just found myself writing this code:

    cdef np.ndarray[real_t, ndim=3] alms = np.zeros((nalms,4,1), dtype=real_dtype)
    cdef np.ndarray[real_t] larr = alms[:,0,0]
    cdef np.ndarray[real_t] marr = alms[:,1,0]
    cdef np.ndarray[real_t] real = alms[:,2,0]
    cdef np.ndarray[real_t] imag = alms[:,3,0]

Here one could actually avoid acquiring four buffers, and instead simply append the trailing indices on accesses. This would mean a lot less variables on the stack.

Note: See TracTickets for help on using tickets.