From f3bb9d21282599204a0b577dc743105150fb8454 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Tue, 23 Jul 2024 23:49:37 +0800 Subject: [PATCH] chore: Update examples to use PolarsAllocator --- example/derive_expression/expression_lib/Cargo.toml | 3 --- example/derive_expression/expression_lib/src/lib.rs | 8 +++----- .../extend_polars/src/lib.rs | 5 ++++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/example/derive_expression/expression_lib/Cargo.toml b/example/derive_expression/expression_lib/Cargo.toml index 8c01ac8..23dc2e7 100644 --- a/example/derive_expression/expression_lib/Cargo.toml +++ b/example/derive_expression/expression_lib/Cargo.toml @@ -14,6 +14,3 @@ pyo3 = { version = "0.21", features = ["abi3-py38"] } pyo3-polars = { version = "*", path = "../../../pyo3-polars", features = ["derive"] } rayon = "1.7.0" serde = { version = "1", features = ["derive"] } - -[target.'cfg(target_os = "linux")'.dependencies] -jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] } diff --git a/example/derive_expression/expression_lib/src/lib.rs b/example/derive_expression/expression_lib/src/lib.rs index d5c6766..0e201d3 100644 --- a/example/derive_expression/expression_lib/src/lib.rs +++ b/example/derive_expression/expression_lib/src/lib.rs @@ -1,9 +1,7 @@ +use pyo3_polars::PolarsAllocator; + mod distances; mod expressions; -#[cfg(target_os = "linux")] -use jemallocator::Jemalloc; - #[global_allocator] -#[cfg(target_os = "linux")] -static ALLOC: Jemalloc = Jemalloc; +static ALLOC: PolarsAllocator = PolarsAllocator::new(); diff --git a/example/extend_polars_python_dispatch/extend_polars/src/lib.rs b/example/extend_polars_python_dispatch/extend_polars/src/lib.rs index fac8510..306cfcb 100644 --- a/example/extend_polars_python_dispatch/extend_polars/src/lib.rs +++ b/example/extend_polars_python_dispatch/extend_polars/src/lib.rs @@ -5,7 +5,10 @@ use polars_lazy::frame::IntoLazy; use polars_lazy::prelude::LazyFrame; use pyo3::prelude::*; use pyo3_polars::error::PyPolarsErr; -use pyo3_polars::{PyDataFrame, PyLazyFrame}; +use pyo3_polars::{PolarsAllocator, PyDataFrame, PyLazyFrame}; + +#[global_allocator] +static ALLOC: PolarsAllocator = PolarsAllocator::new(); #[pyfunction] fn parallel_jaccard(pydf: PyDataFrame, col_a: &str, col_b: &str) -> PyResult {