Open william-silversmith opened 6 years ago
This is difficult to do without making a copy, after all, we have to allocate a buffer equal in size to the original buffer anyway to write to. However, we might not need to make an additional copy on top of it. It might be possible to use realloc
in order to shrink the existing buffer.
I believe the following line is causing two memory copies:
If we instead return a bytes-like object that implements the buffer protocol we can save a copy.
https://cython.readthedocs.io/en/latest/src/userguide/buffer.html