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

Support for python buffer protocol #156

Merged
merged 5 commits into from
Aug 22, 2024
Merged

Support for python buffer protocol #156

merged 5 commits into from
Aug 22, 2024

Conversation

kylebarron
Copy link
Owner

@kylebarron kylebarron commented Aug 20, 2024

Todo:

  • Support in to_numpy(). Not all arrow types will be zero-copy compatible, but all default ones should be

@kylebarron
Copy link
Owner Author

I was able to verify drop behavior too! By putting a dbg inside __releasebuffer__, it printed when I manually deleted the array!!

In [1]: from arro3.core import Array, DataType

In [2]: import numpy as np

In [3]: arr = Array([1, 2, 3, 4], DataType.int64())

In [4]: buf = arr.buffer()

In [5]: np.frombuffer(buf, dtype=np.int64)
Out[5]: array([1, 2, 3, 4])

In [6]: a = np.frombuffer(buf, dtype=np.int64)

In [7]: del a
[pyo3-arrow/src/buffer.rs:56:9] "dropping" = "dropping"

@kylebarron kylebarron marked this pull request as ready for review August 22, 2024 15:30
@kylebarron kylebarron merged commit 705eeca into main Aug 22, 2024
3 checks passed
@kylebarron kylebarron deleted the kyle/buffer-protocol branch August 22, 2024 15:49
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

Successfully merging this pull request may close these issues.

1 participant