Skip to content

Convert a Box<T> into a PyClass #2839

Discussion options

You must be logged in to vote

If you want to hand out references to those Leaf objects to Python code, store them in the Py smart pointer (i.e. on Python's heap with shared mutability using reference counting) instead of using Box.

Note that since using Py implies shared ownership, you might need to use interior mutability of your Leaf structure is not immutable, e.g. using Option<Py<PyCell<Leaf>>> which would the Python-compatible equivalent of Option<Rc<RefCell<Leaf>>.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@adamreichold
Comment options

@JackAshwell11
Comment options

@adamreichold
Comment options

@JackAshwell11
Comment options

@adamreichold
Comment options

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