How to wrap a PyAny in a typeful API? #3844
-
I'm trying to write (a generator for) bindings for Blender's addon API, so I can call it from Rust (effectively using Python just as an ABI). The sticky point is, I can transmute from #[repr(transparent)]
pub struct Mesh(PyAny); but this leaves the questions of
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Sorry for the long delay in response here. You may have come across the These macros haven't been added to the public API and documented yet, we've been working for a long time to figure out the Bound API which has solved several longstanding pain points with PyO3. I would be open to us figuring out how to make these macros part of the public API as we get the older "GIL Refs" API removed. But maybe these macros are mostly unnecessary once the GIL Refs API is gone. In direct answer to your questions:
|
Beta Was this translation helpful? Give feedback.
Sorry for the long delay in response here. You may have come across the
pyobject_native_type
family of macros in PyO3's codebase which are used in PyO3 andrust-numpy
to set up typeful APIs.These macros haven't been added to the public API and documented yet, we've been working for a long time to figure out the Bound API which has solved several longstanding pain points with PyO3. I would be open to us figuring out how to make these macros part of the public API as we get the older "GIL Refs" API removed. But maybe these macros are mostly unnecessary once the GIL Refs API is gone.
In direct answer to your questions:
PyTypeCheck
trait for yourMesh
type. This all…