Skip to content

Conversation

@davidhewitt
Copy link
Member

This PR adds PyBackedStr::clone_ref and PyBackedBytes::clone_ref. This essentially does a reference-counted clone by delegating to Py::clone_ref (except if the bytes are in Rust storage).

This may also help with the closed #5462 in cases where the Python token is available (cc @bschoenmaeckers).

@bschoenmaeckers
Copy link
Member

This is a clean alternative. Thanks!

@davidhewitt davidhewitt added this pull request to the merge queue Nov 28, 2025
Merged via the queue into PyO3:main with commit e2b8265 Nov 28, 2025
43 checks passed
@davidhewitt davidhewitt deleted the pybacked-clone-ref branch November 28, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make PyBackedBytes & PyBackedStr implement Clone without py-clone feature

2 participants