Struct PyObject

Source
pub struct PyObject(/* private fields */);

Implementations§

Source§

impl PyObject

Source

pub fn try_to_value<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<T>
where T: 'a + TryFromBorrowedObject<'a>,

Source

pub fn try_to_ref<'a, T>(&'a self, vm: &VirtualMachine) -> PyResult<&'a Py<T>>
where T: 'a + PyPayload,

Source

pub fn try_value_with<T, F, R>(&self, f: F, vm: &VirtualMachine) -> PyResult<R>
where T: PyPayload, F: Fn(&T) -> PyResult<R>,

Source§

impl PyObject

Source

pub fn try_bytes_like<R>( &self, vm: &VirtualMachine, f: impl FnOnce(&[u8]) -> R, ) -> PyResult<R>

Source

pub fn try_rw_bytes_like<R>( &self, vm: &VirtualMachine, f: impl FnOnce(&mut [u8]) -> R, ) -> PyResult<R>

Source§

impl PyObject

Source

pub fn as_interned_str( &self, vm: &VirtualMachine, ) -> Option<&'static PyStrInterned>

Source§

impl PyObject

Source

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

Source

pub fn get_weak_references(&self) -> Option<Vec<PyRef<PyWeak>>>

Source

pub fn payload_is<T: PyObjectPayload>(&self) -> bool

Source

pub unsafe fn payload_unchecked<T: PyObjectPayload>(&self) -> &T

Force to return payload as T.

§Safety

The actual payload type must be T.

Source

pub fn payload<T: PyObjectPayload>(&self) -> Option<&T>

Source

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

Source

pub fn set_class(&self, typ: PyTypeRef, vm: &VirtualMachine)

Source

pub fn payload_if_exact<T: PyObjectPayload + PyPayload>( &self, vm: &VirtualMachine, ) -> Option<&T>

Source

pub fn dict(&self) -> Option<PyDictRef>

Source

pub fn set_dict(&self, dict: PyDictRef) -> Result<(), PyDictRef>

Set the dict field. Returns Err(dict) if this object does not have a dict field in the first place.

Source

pub fn payload_if_subclass<T: PyPayload>( &self, vm: &VirtualMachine, ) -> Option<&T>

Source

pub fn downcast_ref<T: PyObjectPayload>(&self) -> Option<&Py<T>>

Source

pub fn downcast_ref_if_exact<T: PyObjectPayload + PyPayload>( &self, vm: &VirtualMachine, ) -> Option<&Py<T>>

Source

pub unsafe fn downcast_unchecked_ref<T: PyObjectPayload>(&self) -> &Py<T>

§Safety

T must be the exact payload type

Source

pub fn strong_count(&self) -> usize

Source

pub fn weak_count(&self) -> Option<usize>

Source

pub fn as_raw(&self) -> *const PyObject

Source§

impl PyObject

Source

pub fn to_callable(&self) -> Option<PyCallable<'_>>

Source

pub fn is_callable(&self) -> bool

Source

pub fn call(&self, args: impl IntoFuncArgs, vm: &VirtualMachine) -> PyResult

PyObject_CallArg series

Source

pub fn call_with_args(&self, args: FuncArgs, vm: &VirtualMachine) -> PyResult

PyObject_Call

Source§

impl PyObject

Source

pub fn to_mapping(&self) -> PyMapping<'_>

Source§

impl PyObject

Source§

impl PyObject

Source

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

Takes an object and returns an iterator for it. This is typically a new iterator but if the argument is an iterator, this returns itself.

Source

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

Source

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

Source

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

Source

pub fn call_set_attr( &self, vm: &VirtualMachine, attr_name: &Py<PyStr>, attr_value: PySetterValue, ) -> PyResult<()>

Source

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

Source

pub fn generic_setattr( &self, attr_name: &Py<PyStr>, value: PySetterValue, vm: &VirtualMachine, ) -> PyResult<()>

Source

pub fn generic_getattr(&self, name: &Py<PyStr>, vm: &VirtualMachine) -> PyResult

Source

pub fn generic_getattr_opt( &self, name_str: &Py<PyStr>, dict: Option<PyDictRef>, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>

CPython _PyObject_GenericGetAttrWithDict

Source

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

Source

pub fn rich_compare_bool( &self, other: &Self, opid: PyComparisonOp, vm: &VirtualMachine, ) -> PyResult<bool>

Source

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

Source

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

Source

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

Source

pub fn is_subclass(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool>

Determines if self is a subclass of cls, either directly, indirectly or virtually via the subclasscheck magic method.

Source

pub fn is_instance(&self, cls: &PyObject, vm: &VirtualMachine) -> PyResult<bool>

Determines if self is an instance of cls, either directly, indirectly or virtually via the instancecheck magic method.

Source

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

Source

pub fn obj_type(&self) -> PyObjectRef

Source

pub fn type_check(&self, typ: &Py<PyType>) -> bool

Source

pub fn length_opt(&self, vm: &VirtualMachine) -> Option<PyResult<usize>>

Source

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

Source

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

Source

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

Source

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

Source§

impl PyObject

Source

pub fn to_sequence(&self) -> PySequence<'_>

Trait Implementations§

Source§

impl AsRef<PyObject> for ArgCallable

Source§

fn as_ref(&self) -> &PyObject

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

impl AsRef<PyObject> for ArgMapping

Source§

fn as_ref(&self) -> &PyObject

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

impl<A: AsRef<PyObject>, B: AsRef<PyObject>> AsRef<PyObject> for Either<A, B>

Source§

fn as_ref(&self) -> &PyObject

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<T: PyObjectPayload> AsRef<PyObject> for PyExact<T>

Source§

fn as_ref(&self) -> &PyObject

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

impl<O> AsRef<PyObject> for PyIter<O>
where O: Borrow<PyObject>,

Source§

fn as_ref(&self) -> &PyObject

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

impl AsRef<PyObject> for PyMapping<'_>

Source§

fn as_ref(&self) -> &PyObject

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

impl AsRef<PyObject> for PyObject

Source§

fn as_ref(&self) -> &PyObject

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

impl AsRef<PyObject> for PyObjectRef

Source§

fn as_ref(&self) -> &PyObject

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

impl<T> AsRef<PyObject> for PyRef<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<T: PyObjectPayload> AsRef<PyObject> for PyRefExact<T>

Source§

fn as_ref(&self) -> &PyObject

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

impl Borrow<PyObject> for ArgCallable

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<PyObject> for ArgMapping

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

impl<A: Borrow<PyObject>, B: Borrow<PyObject>> Borrow<PyObject> for Either<A, B>

Source§

fn borrow(&self) -> &PyObject

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> Borrow<PyObject> for PyExact<T>

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

impl<O> Borrow<PyObject> for PyIter<O>
where O: Borrow<PyObject>,

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

impl<'a, T: PyObjectPayload + PyPayload> Borrow<PyObject> for PyLease<'a, T>

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<PyObject> for PyObjectRef

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow(&self) -> &PyObject

Immutably borrows from an owned value. Read more
Source§

impl Debug for PyObject

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> From<&'a PyObject> for PyMapping<'a>

Source§

fn from(obj: &'a PyObject) -> Self

Converts to this type from the input type.
Source§

impl ToOwned for PyObject

Source§

type Owned = PyObjectRef

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 ToPyObject for &PyObject

Source§

impl Traverse for PyObject

Source§

fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)

DO notice that call trace on PyObject means apply tracer_fn on PyObject’s children, not like call trace on PyObjectRef which apply tracer_fn on PyObjectRef itself

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn as_object(&self) -> &PyObject

Source§

fn get_id(&self) -> usize

Source§

fn is<T>(&self, other: &T) -> bool
where 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 T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

fn exact_from(value: T) -> U

Source§

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

Source§

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 T
where 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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

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

Source§

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

Source§

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

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

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

Source§

fn wrapping_into(self) -> U

Source§

impl<T> PyThreadingConstraint for T

Morty Proxy This is a proxified and sanitized view of the page, visit original site.