Skip to content

Commit

Permalink
chore: Switch back to PyO3 0.22 (#19851)
Browse files Browse the repository at this point in the history
Co-authored-by: Itamar Turner-Trauring <[email protected]>
  • Loading branch information
itamarst and pythonspeed authored Nov 19, 2024
1 parent 282ed31 commit f7c6bcc
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 29 deletions.
29 changes: 15 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ memmap = { package = "memmap2", version = "0.7" }
multiversion = "0.7"
ndarray = { version = "0.15", default-features = false }
num-traits = "0.2"
numpy = "0.22"
object_store = { version = "0.10", default-features = false }
once_cell = "1"
parking_lot = "0.12"
percent-encoding = "2.3"
pin-project-lite = "0.2"
pyo3 = "0.21"
pyo3 = "0.22"
rand = "0.8"
rand_distr = "0.4"
raw-cpuid = "11"
Expand Down
4 changes: 1 addition & 3 deletions crates/polars-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ itoa = { workspace = true }
libc = { workspace = true }
ndarray = { workspace = true }
num-traits = { workspace = true }
# TODO: Pin to released version once NumPy 2.0 support is merged
# https://github.com/PyO3/rust-numpy/issues/409
numpy = { git = "https://github.com/stinodego/rust-numpy.git", rev = "9ba9962ae57ba26e35babdce6f179edf5fe5b9c8", default-features = false }
numpy = { workspace = true }
once_cell = { workspace = true }
pyo3 = { workspace = true, features = ["abi3-py39", "chrono", "multiple-pymethods"] }
recursive = { workspace = true }
Expand Down
10 changes: 9 additions & 1 deletion crates/polars-python/src/conversion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,20 @@ impl IntoPy<PyObject> for Wrap<&Schema> {
}
}

#[derive(Clone, Debug)]
#[derive(Debug)]
#[repr(transparent)]
pub struct ObjectValue {
pub inner: PyObject,
}

impl Clone for ObjectValue {
fn clone(&self) -> Self {
Python::with_gil(|py| Self {
inner: self.inner.clone_ref(py),
})
}
}

impl Hash for ObjectValue {
fn hash<H: Hasher>(&self, state: &mut H) {
let h = Python::with_gil(|py| self.inner.bind(py).hash().expect("should be hashable"));
Expand Down
9 changes: 8 additions & 1 deletion crates/polars-python/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ use pyo3::types::{PyBytes, PyString, PyStringMethods};
use crate::error::PyPolarsErr;
use crate::prelude::resolve_homedir;

#[derive(Clone)]
pub struct PyFileLikeObject {
inner: PyObject,
}

impl Clone for PyFileLikeObject {
fn clone(&self) -> Self {
Python::with_gil(|py| Self {
inner: self.inner.clone_ref(py),
})
}
}

/// Wraps a `PyObject`, and implements read, seek, and write for it.
impl PyFileLikeObject {
/// Creates an instance of a `PyFileLikeObject` from a `PyObject`.
Expand Down
16 changes: 8 additions & 8 deletions crates/polars-python/src/lazyframe/visitor/expr_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub struct Literal {
dtype: PyObject,
}

#[pyclass(name = "Operator")]
#[derive(Copy, Clone)]
#[pyclass(name = "Operator", eq)]
#[derive(Copy, Clone, PartialEq)]
pub enum PyOperator {
Eq,
EqValidity,
Expand Down Expand Up @@ -116,8 +116,8 @@ impl IntoPy<PyObject> for Wrap<InequalityOperator> {
}
}

#[pyclass(name = "StringFunction")]
#[derive(Copy, Clone)]
#[pyclass(name = "StringFunction", eq)]
#[derive(Copy, Clone, PartialEq)]
pub enum PyStringFunction {
ConcatHorizontal,
ConcatVertical,
Expand Down Expand Up @@ -171,8 +171,8 @@ impl PyStringFunction {
}
}

#[pyclass(name = "BooleanFunction")]
#[derive(Copy, Clone)]
#[pyclass(name = "BooleanFunction", eq)]
#[derive(Copy, Clone, PartialEq)]
pub enum PyBooleanFunction {
Any,
All,
Expand Down Expand Up @@ -200,8 +200,8 @@ impl PyBooleanFunction {
}
}

#[pyclass(name = "TemporalFunction")]
#[derive(Copy, Clone)]
#[pyclass(name = "TemporalFunction", eq)]
#[derive(Copy, Clone, PartialEq)]
pub enum PyTemporalFunction {
Millennium,
Century,
Expand Down
8 changes: 7 additions & 1 deletion crates/polars-utils/src/python_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ pub use serde_wrap::{
SERDE_MAGIC_BYTE_MARK as PYTHON_SERDE_MAGIC_BYTE_MARK,
};

#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct PythonFunction(pub PyObject);

impl Clone for PythonFunction {
fn clone(&self) -> Self {
Python::with_gil(|py| Self(self.0.clone_ref(py)))
}
}

impl From<PyObject> for PythonFunction {
fn from(value: PyObject) -> Self {
Self(value)
Expand Down

0 comments on commit f7c6bcc

Please sign in to comment.