You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have memoryview supported to support zero-copying. Currently it seems that only bytes are supported which can't share memory with other objects
The text was updated successfully, but these errors were encountered:
Do you mean for the methods Socket.send() and Socket.asend()? (and similarly for the pipe and context methods?) Or did you have something else in mind?
It is possible to use a memoryview for sending - currently, you need to pierce through the abstraction and use the ffi instance from pynng in your user code, to convert it into an object that is understood by cffi. For example like this:
frompynngimportffiimportnumpyasnpdata=np.zeros(128) # or whatever - just needs to support the buffer protocolmv=memoryview(data)
your_socket.send(ffi.from_buffer(mv))
Maybe this could be directly supported in the send method, by wrapping the object to send into a from_buffer if it is a memoryview? Or even directly support objects that implement the buffer protocol, so one can directly call your_socket.send(some_numpy_array)
It would be nice to have
memoryview
supported to support zero-copying. Currently it seems that onlybytes
are supported which can't share memory with other objectsThe text was updated successfully, but these errors were encountered: