pub trait EnterPolarsExt {
// Required method
fn enter_polars<T, E, F>(self, f: F) -> PyResult<T>
where F: Ungil + Send + FnOnce() -> Result<T, E>,
T: Ungil + Send,
E: Ungil + Send + Into<PyPolarsErr>;
// Provided methods
fn enter_polars_ok<T, F>(self, f: F) -> PyResult<T>
where Self: Sized,
F: Ungil + Send + FnOnce() -> T,
T: Ungil + Send { ... }
fn enter_polars_df<F>(self, f: F) -> PyResult<PyDataFrame>
where Self: Sized,
F: Ungil + Send + FnOnce() -> PolarsResult<DataFrame> { ... }
fn enter_polars_series<T, F>(self, f: F) -> PyResult<PySeries>
where Self: Sized,
T: Ungil + Send + IntoSeries,
F: Ungil + Send + FnOnce() -> PolarsResult<T> { ... }
}
Required Methods§
Sourcefn enter_polars<T, E, F>(self, f: F) -> PyResult<T>
fn enter_polars<T, E, F>(self, f: F) -> PyResult<T>
Whenever you have a block of code in the public Python API that (potentially) takes a long time, wrap it in enter_polars. This will ensure we release the GIL and catch KeyboardInterrupts.
This not only can increase performance and usability, it can avoid deadlocks on the GIL for Python UDFs.
Provided Methods§
Sourcefn enter_polars_ok<T, F>(self, f: F) -> PyResult<T>
fn enter_polars_ok<T, F>(self, f: F) -> PyResult<T>
Same as enter_polars, but wraps the result in PyResult::Ok, useful shorthand for infallible functions.
Sourcefn enter_polars_df<F>(self, f: F) -> PyResult<PyDataFrame>
fn enter_polars_df<F>(self, f: F) -> PyResult<PyDataFrame>
Same as enter_polars, but expects a PolarsResult
Sourcefn enter_polars_series<T, F>(self, f: F) -> PyResult<PySeries>
fn enter_polars_series<T, F>(self, f: F) -> PyResult<PySeries>
Same as enter_polars, but expects a PolarsResult as return which
is converted to a PySeries through S: IntoSeries.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.