Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate adding the Python Buffer Protocol on the memory #135

Closed
thewtex opened this issue Mar 14, 2023 · 1 comment
Closed

Investigate adding the Python Buffer Protocol on the memory #135

thewtex opened this issue Mar 14, 2023 · 1 comment

Comments

@thewtex
Copy link
Contributor

thewtex commented Mar 14, 2023

If possible, this would help with efficient use of memory and provide a convenient developer interface.

The Python Buffer Protocol enables creating, e.g. NumPy array views on the memory with np.frombuffer.

xref #81

@thewtex thewtex changed the title Investigate the addition of the Python Buffer Protocol on the memory Investigate adding the Python Buffer Protocol on the memory Mar 14, 2023
@thewtex
Copy link
Contributor Author

thewtex commented Mar 20, 2023

Done per:

np_mem = np.frombuffer(memory.get_buffer_ptr(store), dtype=np.uint8)
np_mem[start:end] = A # write
B = np_mem[start:end] # read

thanks to refactoring by @muayyad-alsadi 🎉 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant