From 1dbf82c0a7c7ebdd3f28be9663030581a3c7100d Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Wed, 17 Jun 2026 23:36:35 -0400 Subject: [PATCH] feat(pyo3-bytes) add Clone and Default to PyBytes --- pyo3-bytes/CHANGELOG.md | 5 +++++ pyo3-bytes/Cargo.toml | 2 +- pyo3-bytes/src/bytes.rs | 11 +++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 pyo3-bytes/CHANGELOG.md diff --git a/pyo3-bytes/CHANGELOG.md b/pyo3-bytes/CHANGELOG.md new file mode 100644 index 00000000..abb91b69 --- /dev/null +++ b/pyo3-bytes/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 0.7.1 - 2026-06-17 + +Add `#[derive(Clone)]` and `#[derive(Default)]` to `PyBytes`. diff --git a/pyo3-bytes/Cargo.toml b/pyo3-bytes/Cargo.toml index 4a493041..13ec2e02 100644 --- a/pyo3-bytes/Cargo.toml +++ b/pyo3-bytes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-bytes" -version = "0.7.0" +version = "0.7.1" authors = [ "Kyle Barron ", "jesse rubin ", diff --git a/pyo3-bytes/src/bytes.rs b/pyo3-bytes/src/bytes.rs index b1c55367..1fd5aa70 100644 --- a/pyo3-bytes/src/bytes.rs +++ b/pyo3-bytes/src/bytes.rs @@ -32,8 +32,15 @@ use pyo3::{ffi, IntoPyObjectExt}; /// data view without copies. In Python, this `PyBytes` object can be passed to Python `bytes` or /// `memoryview` constructors, `numpy.frombuffer`, or any other function that supports buffer /// protocol input. -#[pyclass(name = "Bytes", subclass, frozen, sequence, weakref)] -#[derive(Hash, PartialEq, PartialOrd, Eq, Ord)] +#[pyclass( + name = "Bytes", + subclass, + frozen, + sequence, + weakref, + skip_from_py_object +)] +#[derive(Clone, Default, Hash, PartialEq, PartialOrd, Eq, Ord)] pub struct PyBytes(Bytes); impl AsRef for PyBytes {