pub struct Py<T>(/* private fields */);Implementations§
Source§impl Py<PyDict>
impl Py<PyDict>
Sourcepub fn to_attributes(
&self,
vm: &VirtualMachine,
) -> IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>
pub fn to_attributes( &self, vm: &VirtualMachine, ) -> IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>
Take a python dictionary and convert it to attributes.
pub fn get_item_opt<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>
pub fn get_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult
pub fn set_item<K: DictKey + ?Sized>( &self, key: &K, value: PyObjectRef, vm: &VirtualMachine, ) -> PyResult<()>
pub fn del_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult<()>
pub fn pop_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>
pub fn get_chain<K: DictKey + ?Sized>( &self, other: &Self, key: &K, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>
Source§impl Py<PyFunction>
impl Py<PyFunction>
pub fn invoke_with_locals( &self, func_args: FuncArgs, locals: Option<ArgMapping>, vm: &VirtualMachine, ) -> PyResult
pub fn invoke(&self, func_args: FuncArgs, vm: &VirtualMachine) -> PyResult
Sourcepub fn func_version(&self) -> u32
pub fn func_version(&self) -> u32
Returns the function version, or 0 if invalidated.
Sourcepub fn get_version_for_current_state(&self) -> u32
pub fn get_version_for_current_state(&self) -> u32
Returns the current version, assigning a fresh one if previously invalidated.
Returns 0 if the version counter has overflowed.
_PyFunction_GetVersionForCurrentState
Sourcepub fn invoke_exact_args(
&self,
args: Vec<PyObjectRef>,
vm: &VirtualMachine,
) -> PyResult
pub fn invoke_exact_args( &self, args: Vec<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult
Fast path for calling a simple function with exact positional args. Skips FuncArgs allocation, prepend_arg, and fill_locals_from_args. Only valid when: CO_OPTIMIZED, no VARARGS, no VARKEYWORDS, no kwonlyargs, and nargs == co_argcount.
Source§impl Py<PyModule>
impl Py<PyModule>
pub fn __init_methods(&self, vm: &VirtualMachine) -> PyResult<()>
pub fn dict(&self) -> PyDictRef
pub fn get_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine, ) -> PyResult
pub fn set_attr<'a>( &self, attr_name: impl AsPyStr<'a>, attr_value: impl Into<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<()>
Source§impl Py<PyStr>
impl Py<PyStr>
pub fn try_as_utf8<'a>( &'a self, vm: &VirtualMachine, ) -> PyResult<&'a Py<PyUtf8Str>>
Source§impl Py<PyType>
impl Py<PyType>
Sourcepub fn check_exact<'a>(
obj: &'a PyObject,
vm: &VirtualMachine,
) -> Option<&'a Self>
pub fn check_exact<'a>( obj: &'a PyObject, vm: &VirtualMachine, ) -> Option<&'a Self>
Equivalent to CPython’s PyType_CheckExact macro Checks if obj is exactly a type (not a subclass)
Sourcepub fn fast_issubclass(&self, cls: &impl Borrow<PyObject>) -> bool
pub fn fast_issubclass(&self, cls: &impl Borrow<PyObject>) -> bool
Determines if subclass is actually a subclass of cls, this doesn’t call subclasscheck,
so only use this if cls is known to have not overridden the base subclasscheck magic
method.
pub fn mro_map_collect<F, R>(&self, f: F) -> Vec<R>where
F: Fn(&Self) -> R,
pub fn mro_collect(&self) -> Vec<PyRef<PyType>>
pub fn iter_base_chain(&self) -> impl Iterator<Item = &Self>
pub fn extend_methods( &'static self, method_defs: &'static [PyMethodDef], ctx: &Context, )
Source§impl Py<Frame>
impl Py<Frame>
pub fn run(&self, vm: &VirtualMachine) -> PyResult<ExecutionResult>
pub fn yield_from_target(&self) -> Option<PyObjectRef>
pub fn is_internal_frame(&self) -> bool
pub fn next_external_frame(&self, vm: &VirtualMachine) -> Option<FrameRef>
Source§impl Py<HeapMethodDef>
impl Py<HeapMethodDef>
pub fn build_function(&self, vm: &VirtualMachine) -> PyRef<PyNativeFunction>
pub fn build_method( &self, class: &'static Py<PyType>, vm: &VirtualMachine, ) -> PyRef<PyMethodDescriptor>
Source§impl<T: PyPayload> Py<T>
impl<T: PyPayload> Py<T>
pub fn downgrade( &self, callback: Option<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<PyWeakRef<T>>
pub fn payload(&self) -> &T
Source§impl<T: PySubclass> Py<T>
impl<T: PySubclass> Py<T>
Sourcepub fn upcast_ref<U: PyPayload + StaticType>(&self) -> &Py<U>where
T: StaticType,
pub fn upcast_ref<U: PyPayload + StaticType>(&self) -> &Py<U>where
T: StaticType,
Converts &Py<T> to &Py<U> where U is an ancestor type.
Trait Implementations§
Source§impl<'a> IntoIterator for &'a Py<PyDict>
impl<'a> IntoIterator for &'a Py<PyDict>
Source§impl<'a, R> IntoIterator for &'a Py<PyTuple<R>>
impl<'a, R> IntoIterator for &'a Py<PyTuple<R>>
Source§impl<T> ToOwned for Py<T>
impl<T> ToOwned for Py<T>
Source§impl<T: MaybeTraverse> Traverse for Py<T>
impl<T: MaybeTraverse> Traverse for Py<T>
Source§fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
DO notice that call trace on Py<T> means apply tracer_fn on Py<T>’s children,
not like call trace on PyRef<T> which apply tracer_fn on PyRef<T> itself
Source§fn clear(&mut self, _out: &mut Vec<PyObjectRef>)
fn clear(&mut self, _out: &mut Vec<PyObjectRef>)
Source§impl<'a, T: PyPayload> TryFromBorrowedObject<'a> for &'a Py<T>
impl<'a, T: PyPayload> TryFromBorrowedObject<'a> for &'a Py<T>
Source§fn try_from_borrowed_object(
vm: &VirtualMachine,
obj: &'a PyObject,
) -> PyResult<Self>
fn try_from_borrowed_object( vm: &VirtualMachine, obj: &'a PyObject, ) -> PyResult<Self>
impl<T> Eq for Py<T>
Auto Trait Implementations§
impl<T> !Freeze for Py<T>
impl<T> !RefUnwindSafe for Py<T>
impl<T> !Send for Py<T>
impl<T> !Sync for Py<T>
impl<T> !Unpin for Py<T>
impl<T> !UnsafeUnpin for Py<T>
impl<T> !UnwindSafe for Py<T>
Blanket Implementations§
Source§impl<T> AsObject for T
impl<T> AsObject for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
Source§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more