paleolimbot opened a new pull request, #817:
URL: https://github.com/apache/arrow-nanoarrow/pull/817
This PR adds the s3 generics required to interact with Python objects via
reticulate. Thie relies on nanoarrow for Python, which also exposes primitives
for interacting with capsules. In theory we wouldn't need nanoarrow for Python
for the Python -> R case if we could create and consume PyCapsules but this is
at least a good start!
``` r
library(nanoarrow)
library(reticulate)
pa <- import("pyarrow", convert = FALSE)
x <- pa$array(c(1, 2, 3))
(array <- as_nanoarrow_array(x))
#> <nanoarrow_array double[3]>
#> $ length : int 3
#> $ null_count: int 0
#> $ offset : int 0
#> $ buffers :List of 2
#> ..$ :<nanoarrow_buffer validity<bool>[null] ``
#> ..$ :<nanoarrow_buffer data<double>[3][24 b]> `1 2 3`
#> $ dictionary: NULL
#> $ children : list()
(py_array <- r_to_py(array))
#> nanoarrow.Array<double>[3]
#> 1.0
#> 2.0
#> 3.0
py_to_r(py_array)
#> <nanoarrow_array double[3]>
#> $ length : int 3
#> $ null_count: int 0
#> $ offset : int 0
#> $ buffers :List of 2
#> ..$ :<nanoarrow_buffer validity<bool>[null] ``
#> ..$ :<nanoarrow_buffer data<double>[3][24 b]> `1 2 3`
#> $ dictionary: NULL
#> $ children : list()
```
Closes #810.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]