Skip to content

Convert Python bytes and strings to Elixir binaries without copying #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

jonatanklosko
Copy link
Member

bytes are immutable and PyBytes_AsStringAndSize returns pointer to the buffer. Similarly str are immutable and PyUnicode_AsUTF8AndSize returns a pointer to cached buffer that lives as long as the object.

Currently we create a new Erlang binary, which means copying the data once. This PR changes it such that we create resource around the Python objects and create a zero-copy resource binary term.

@jonatanklosko jonatanklosko merged commit ece1b80 into main Mar 7, 2025
9 checks passed
@jonatanklosko jonatanklosko deleted the jk-binaries branch March 7, 2025 08:54
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.

2 participants