diff --git a/arro3-core/python/arro3/core/_buffer.pyi b/arro3-core/python/arro3/core/_buffer.pyi index 8af551b..8783083 100644 --- a/arro3-core/python/arro3/core/_buffer.pyi +++ b/arro3-core/python/arro3/core/_buffer.pyi @@ -7,6 +7,7 @@ else: class Buffer(_Buffer): """An Arrow Buffer""" + def __eq__(self, value: object) -> bool: ... def __init__(self, buffer) -> None: ... def __buffer__(self, flags: int) -> memoryview: ... def __len__(self) -> int: ... diff --git a/pyo3-arrow/src/buffer.rs b/pyo3-arrow/src/buffer.rs index 11d0d56..1f79663 100644 --- a/pyo3-arrow/src/buffer.rs +++ b/pyo3-arrow/src/buffer.rs @@ -41,7 +41,8 @@ use crate::PyArray; /// The Python buffer protocol is implemented on this buffer to enable zero-copy data transfer of /// the core buffer into Python. This allows for zero-copy data sharing with numpy via /// `numpy.frombuffer`. -#[pyclass(module = "arro3.core._core", name = "Buffer", subclass, frozen)] +#[derive(PartialEq)] +#[pyclass(module = "arro3.core._core", name = "Buffer", subclass, frozen, eq)] pub struct PyArrowBuffer(Buffer); impl AsRef for PyArrowBuffer { diff --git a/pyo3-arrow/src/chunked.rs b/pyo3-arrow/src/chunked.rs index 84d212a..c9108b5 100644 --- a/pyo3-arrow/src/chunked.rs +++ b/pyo3-arrow/src/chunked.rs @@ -27,8 +27,14 @@ use crate::{PyArray, PyDataType, PyField, PyScalar}; /// A Python-facing Arrow chunked array. /// /// This is a wrapper around a [FieldRef] and a `Vec` of [ArrayRef]. -#[derive(Debug)] -#[pyclass(module = "arro3.core._core", name = "ChunkedArray", subclass, frozen)] +#[derive(Debug, PartialEq)] +#[pyclass( + module = "arro3.core._core", + name = "ChunkedArray", + subclass, + frozen, + eq +)] pub struct PyChunkedArray { chunks: Vec, field: FieldRef, @@ -353,10 +359,6 @@ impl PyChunkedArray { ) } - fn __eq__(&self, other: &PyChunkedArray) -> bool { - self.field == other.field && self.chunks == other.chunks - } - fn __getitem__(&self, i: isize) -> PyArrowResult { // Handle negative indexes from the end let mut i = if i < 0 { diff --git a/pyo3-arrow/src/datatypes.rs b/pyo3-arrow/src/datatypes.rs index b6bcb8d..861a498 100644 --- a/pyo3-arrow/src/datatypes.rs +++ b/pyo3-arrow/src/datatypes.rs @@ -34,7 +34,7 @@ impl<'a> FromPyObject<'_, 'a> for PyTimeUnit { /// A Python-facing wrapper around [DataType]. #[derive(PartialEq, Eq, Debug)] -#[pyclass(module = "arro3.core._core", name = "DataType", subclass, frozen)] +#[pyclass(module = "arro3.core._core", name = "DataType", subclass, frozen, eq)] pub struct PyDataType(DataType); impl PyDataType { @@ -135,10 +135,6 @@ impl PyDataType { to_schema_pycapsule(py, &self.0) } - fn __eq__(&self, other: PyDataType) -> bool { - self.equals(other, false) - } - fn __hash__(&self) -> u64 { let mut hasher = DefaultHasher::new(); self.0.hash(&mut hasher); diff --git a/pyo3-arrow/src/field.rs b/pyo3-arrow/src/field.rs index cea8303..bec21d6 100644 --- a/pyo3-arrow/src/field.rs +++ b/pyo3-arrow/src/field.rs @@ -19,8 +19,8 @@ use crate::PyDataType; /// A Python-facing Arrow field. /// /// This is a wrapper around a [FieldRef]. -#[derive(Debug)] -#[pyclass(module = "arro3.core._core", name = "Field", subclass, frozen)] +#[derive(Debug, PartialEq)] +#[pyclass(module = "arro3.core._core", name = "Field", subclass, frozen, eq)] pub struct PyField(FieldRef); impl PyField { @@ -129,10 +129,6 @@ impl PyField { to_schema_pycapsule(py, self.0.as_ref()) } - fn __eq__(&self, other: &PyField) -> bool { - self.0 == other.0 - } - fn __repr__(&self) -> String { self.to_string() } diff --git a/pyo3-arrow/src/record_batch.rs b/pyo3-arrow/src/record_batch.rs index 158396f..42a49f8 100644 --- a/pyo3-arrow/src/record_batch.rs +++ b/pyo3-arrow/src/record_batch.rs @@ -26,8 +26,14 @@ use crate::{PyArray, PyField, PySchema}; /// A Python-facing Arrow record batch. /// /// This is a wrapper around a [RecordBatch]. -#[pyclass(module = "arro3.core._core", name = "RecordBatch", subclass, frozen)] -#[derive(Debug)] +#[pyclass( + module = "arro3.core._core", + name = "RecordBatch", + subclass, + frozen, + eq +)] +#[derive(Debug, PartialEq)] pub struct PyRecordBatch(RecordBatch); impl PyRecordBatch { @@ -196,10 +202,6 @@ impl PyRecordBatch { to_schema_pycapsule(py, self.0.schema_ref().as_ref()) } - fn __eq__(&self, other: &PyRecordBatch) -> bool { - self.0 == other.0 - } - fn __getitem__(&self, key: FieldIndexInput) -> PyResult { self.column(key) } diff --git a/pyo3-arrow/src/schema.rs b/pyo3-arrow/src/schema.rs index 4621b4f..81a77e8 100644 --- a/pyo3-arrow/src/schema.rs +++ b/pyo3-arrow/src/schema.rs @@ -19,8 +19,8 @@ use crate::{PyDataType, PyField, PyTable}; /// A Python-facing Arrow schema. /// /// This is a wrapper around a [SchemaRef]. -#[derive(Debug)] -#[pyclass(module = "arro3.core._core", name = "Schema", subclass, frozen)] +#[derive(Debug, PartialEq)] +#[pyclass(module = "arro3.core._core", name = "Schema", subclass, frozen, eq)] pub struct PySchema(SchemaRef); impl PySchema { @@ -140,10 +140,6 @@ impl PySchema { to_schema_pycapsule(py, self.0.as_ref()) } - fn __eq__(&self, other: &PySchema) -> bool { - self.0 == other.0 - } - fn __getitem__(&self, key: FieldIndexInput) -> PyArrowResult { self.field(key) } diff --git a/pyo3-arrow/src/table.rs b/pyo3-arrow/src/table.rs index 3dd7132..7e16c50 100644 --- a/pyo3-arrow/src/table.rs +++ b/pyo3-arrow/src/table.rs @@ -33,8 +33,8 @@ use crate::{PyChunkedArray, PyField, PyRecordBatch, PyRecordBatchReader, PySchem /// A Python-facing Arrow table. /// /// This is a wrapper around a [SchemaRef] and a `Vec` of [RecordBatch]. -#[pyclass(module = "arro3.core._core", name = "Table", subclass, frozen)] -#[derive(Debug)] +#[pyclass(module = "arro3.core._core", name = "Table", subclass, frozen, eq)] +#[derive(Debug, PartialEq)] pub struct PyTable { batches: Vec, schema: SchemaRef, @@ -273,10 +273,6 @@ impl PyTable { ) } - fn __eq__(&self, other: &PyTable) -> bool { - self.batches == other.batches && self.schema == other.schema - } - fn __getitem__(&self, key: FieldIndexInput) -> PyArrowResult { self.column(key) }