Trait pyo3::PyNativeType

source ·
pub unsafe trait PyNativeType: Sized {
    fn py(&self) -> Python<'_> { ... }
    unsafe fn unchecked_downcast(obj: &PyAny) -> &Self { ... }
Expand description

Types that are built into the Python interpreter.

PyO3 is designed in a way that all references to those types are bound to the GIL, which is why you can get a token from all references of those types.


This trait must only be implemented for types which cannot be accessed without the GIL.

Provided Methods§

Returns a GIL marker constrained to the lifetime of this type.

Cast &PyAny to &Self without no type checking.


obj must have the same layout as *const ffi::PyObject and must be an instance of a type corresponding to Self.