Skip to content

Can python objects reference the Rust heap? #3737

Discussion options

You must be logged in to vote

In the specific case you mention, yes, since that method will copy the memory into the new Bytes object (those always have their allocation on the Python heap).

The way to use arbitrary memory is with buffers/memoryviews, and those are specifically meant for representing non Python data, so no problem referencing a leaked Rust object.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ShaneMurphy2
Comment options

@adamreichold
Comment options

@ShaneMurphy2
Comment options

Answer selected by ShaneMurphy2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants