Ticket #177 (new enhancement)

Opened 4 years ago

Last modified 2 years ago

Efficient cdef calling convention for buffers

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

Description (last modified by dagss) (diff)

Currently there's no way of creating efficient functions taking a buffer argument -- for starters cdef functions doesn't support declaring an argument as a buffer, and even if it did, it would mean a costly (in this context) buffer acquisition on every call.

An attractive alternative would be to have

cdef utilfunc(object[int] buf): ...

mean a different calling convention, where the caller must acquire the buffer, and a struct with the necesarry information is passed. If the caller already has a buffer then it can simply pass the information it already has.

(There's a subtlety here: If buf is reassigned to in utilfunc, then the original buffer must not be released, while the new buffer must be released eventually.)

Change History

Changed 4 years ago by dagss

  • summary changed from Effective cdef calling convention for buffers to Efficient cdef calling convention for buffers

Changed 4 years ago by dagss

  • description modified (diff)

Changed 4 years ago by dagss

One can simply disable reassigning to the argument in the function initially.

Changed 4 years ago by dagss

  • keywords kurtgsoc added

Changed 2 years ago by scoder

Also see #180, #340.

Changed 2 years ago by robertwb

This is also related to being able to handle buffers from closures #660.

Note: See TracTickets for help on using tickets.