-
Notifications
You must be signed in to change notification settings - Fork 36
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
Polars Expression plugins for R #1024
Comments
Note: Serialization and deserialization of R objects that may be needed are already defined here (I don't know if this is sufficient) r-polars/src/rust/src/rbackground.rs Lines 77 to 131 in 1ea820b
|
I was able to make this work in an implementation that I am rewriting from scratch using py-polars as a reference. # s: polars series
math_shortcuts <- function(s) {
# Create a new environment to store the methods
self <- new.env(parent = emptyenv())
# Store the series
self$`_s` <- s
# Add methods
self$square <- function() self$`_s` * self$`_s`
self$cube <- function() self$`_s` * self$`_s` * self$`_s`
# Set the class
class(self) <- "polars_namespace_series"
# Return the environment
self
}
polars_api_register_series_namespace("math", math_shortcuts)
s <- as_polars_series(c(1.5, 31, 42, 64.5))
s$math$square()$rename("s^2")
s <- as_polars_series(1:5)
s$math$cube()$rename("s^3") The current concern is performance degradation due to frequent for loops (basically each call to a single method). |
I have looked into this and it appears that this is accomplished by connecting to a dynamic library via the libloading crate. In the case of R packages, it is the static libraries, not the dynamic libraries, that are built by rustc. We need to find a way to generate the proper expected C ABI on the plugin side, but this is obviously beyond my knowledge. |
The recent |
My understanding is that dynamic libraries are built by R, so it doesn't matter which Rust crate is chosen to build the static library. |
We needs:
The text was updated successfully, but these errors were encountered: