Struct rustpython_vm::object::Py

source ·
#[repr(transparent)]
pub struct Py<T: PyObjectPayload>(_);

Implementations§

source§

impl Py<PyDict>

source

pub fn to_attributes( &self, vm: &VirtualMachine ) -> IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>

Take a python dictionary and convert it to attributes.

source

pub fn get_item_opt<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine ) -> PyResult<Option<PyObjectRef>>

source

pub fn get_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine ) -> PyResult

source

pub fn set_item<K: DictKey + ?Sized>( &self, key: &K, value: PyObjectRef, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn del_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine ) -> PyResult<()>

source

pub fn get_chain<K: DictKey + ?Sized>( &self, other: &Self, key: &K, vm: &VirtualMachine ) -> PyResult<Option<PyObjectRef>>

source§

impl Py<Frame>

source

pub fn f_back(&self, vm: &VirtualMachine) -> Option<PyRef<Frame>>

source§

impl Py<PyModule>

source

pub fn __init_methods(&self, vm: &VirtualMachine) -> PyResult<()>

source

pub fn dict(&self) -> PyDictRef

source

pub fn get_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine ) -> PyResult

source

pub fn set_attr<'a>( &self, attr_name: impl AsPyStr<'a>, attr_value: impl Into<PyObjectRef>, vm: &VirtualMachine ) -> PyResult<()>

source§

impl Py<PyType>

source

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.

source

pub fn iter_mro( &self ) -> impl Iterator<Item = &Py<PyType>> + DoubleEndedIterator

source

pub fn iter_base_chain(&self) -> impl Iterator<Item = &Py<PyType>>

source

pub fn extend_methods( &'static self, method_defs: &'static [PyMethodDef], ctx: &Context )

source§

impl Py<Frame>

source§

impl Py<HeapMethodDef>

source

pub fn build_function(&self, vm: &VirtualMachine) -> PyRef<PyNativeFunction>

source

pub fn build_method( &self, class: &'static Py<PyType>, vm: &VirtualMachine ) -> PyRef<PyMethodDescriptor>

source§

impl Py<PyWeak>

source

pub fn upgrade(&self) -> Option<PyObjectRef>

source§

impl<T: PyObjectPayload> Py<T>

source

pub fn downgrade( &self, callback: Option<PyObjectRef>, vm: &VirtualMachine ) -> PyResult<PyWeakRef<T>>

Trait Implementations§

source§

impl<T: PyObjectPayload> AsRef<Py<T>> for PyExact<T>

source§

fn as_ref(&self) -> &Py<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> AsRef<Py<T>> for PyRef<T>where T: PyObjectPayload,

source§

fn as_ref(&self) -> &Py<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: PyObjectPayload> AsRef<Py<T>> for PyRefExact<T>

source§

fn as_ref(&self) -> &Py<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> AsRef<PyObject> for Py<T>where T: PyObjectPayload,

source§

fn as_ref(&self) -> &PyObject

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<str> for Py<PyStr>

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: PyObjectPayload> Borrow<Py<T>> for PyExact<T>

source§

fn borrow(&self) -> &Py<T>

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Py<T>> for PyRef<T>where T: PyObjectPayload,

source§

fn borrow(&self) -> &Py<T>

Immutably borrows from an owned value. Read more
source§

impl<T: PyObjectPayload> Borrow<Py<T>> for PyRefExact<T>

source§

fn borrow(&self) -> &Py<T>

Immutably borrows from an owned value. Read more
source§

impl<T: PyObjectPayload> Borrow<PyObject> for Py<T>

source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
source§

impl<T: PyObjectPayload> Debug for Py<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: PyObjectPayload> Deref for Py<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> Display for Py<T>where T: PyObjectPayload + Display,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T: PyObjectPayload> From<&'a Py<T>> for &'a PyObject

source§

fn from(py_ref: &'a Py<T>) -> Self

Converts to this type from the input type.
source§

impl<'a> IntoIterator for &'a Py<PyDict>

§

type Item = (PyObjectRef, PyObjectRef)

The type of the elements being iterated over.
§

type IntoIter = DictIter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a> IntoIterator for &'a Py<PyTuple>

§

type Item = &'a PyObjectRef

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, PyObjectRef>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: PyObjectPayload> ToOwned for Py<T>

§

type Owned = PyRef<T>

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T: PyObjectPayload> Traverse for Py<T>

source§

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§

impl<'a, T: PyPayload> TryFromBorrowedObject<'a> for &'a Py<T>

source§

fn try_from_borrowed_object( vm: &VirtualMachine, obj: &'a PyObject ) -> PyResult<Self>

Attempt to convert a Python object to a value of this type.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Py<T>

§

impl<T> !Send for Py<T>

§

impl<T> !Sync for Py<T>

§

impl<T> Unpin for Py<T>where T: Unpin,

§

impl<T> !UnwindSafe for Py<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsObject for Twhere T: Borrow<PyObject>,

source§

fn as_object(&self) -> &PyObject

source§

fn get_id(&self) -> usize

source§

fn is<T>(&self, other: &T) -> boolwhere T: AsObject,

source§

fn class(&self) -> &Py<PyType>

source§

fn get_class_attr( &self, attr_name: &'static PyStrInterned ) -> Option<PyObjectRef>

source§

fn fast_isinstance(&self, cls: &Py<PyType>) -> bool

Determines if obj actually an instance of cls, this doesn’t call instancecheck, so only use this if cls is known to have not overridden the base instancecheck magic method.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> ExactFrom<T> for Uwhere U: TryFrom<T>,

§

fn exact_from(value: T) -> U

§

impl<T, U> ExactInto<U> for Twhere U: ExactFrom<T>,

§

fn exact_into(self) -> U

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> OverflowingInto<U> for Twhere U: OverflowingFrom<T>,

§

fn overflowing_into(self) -> (U, bool)

§

impl<T, U> RoundingInto<U> for Twhere U: RoundingFrom<T>,

§

fn rounding_into(self, rm: RoundingMode) -> U

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T, U> SaturatingInto<U> for Twhere U: SaturatingFrom<T>,

§

fn saturating_into(self) -> U

§

impl<T> ToDebugString for Twhere T: Debug,

§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> WrappingInto<U> for Twhere U: WrappingFrom<T>,

§

fn wrapping_into(self) -> U

source§

impl<T> PyThreadingConstraint for T