Python has this API for locking a buffer and releasing it afterwards: https://docs.python.org/3/c-api/buffer.html#c.PyBuffer_Release
The way I've used it in the past is to avoid copying data when doing asynchronous writes. You could lock the buffer, get it's data pointer and pass it to libuv for example, since you know it will remain valid and stable. All one needs to do is to keep the Python object alive, which is simple to do by just bumping the refcount.
On to QuickJS :-) I found myself in the same situation. But now we have immutable aray buffers! I'd love to have a way to set / reset the flag from C, so I could keep the chunk I'm sending alive until libuv is done with it.
Say something like: JSArrayBuffer{Get,Set}Immutable(JSContext *ctx, JSObject obj, bool set).
Thoughts?
@bnoordhuis
Python has this API for locking a buffer and releasing it afterwards: https://docs.python.org/3/c-api/buffer.html#c.PyBuffer_Release
The way I've used it in the past is to avoid copying data when doing asynchronous writes. You could lock the buffer, get it's data pointer and pass it to libuv for example, since you know it will remain valid and stable. All one needs to do is to keep the Python object alive, which is simple to do by just bumping the refcount.
On to QuickJS :-) I found myself in the same situation. But now we have immutable aray buffers! I'd love to have a way to set / reset the flag from C, so I could keep the chunk I'm sending alive until libuv is done with it.
Say something like:
JSArrayBuffer{Get,Set}Immutable(JSContext *ctx, JSObject obj, bool set).Thoughts?
@bnoordhuis