[][src]Struct pyo3::PyObject

#[repr(transparent)]
pub struct PyObject(_);

A python object

The python object's lifetime is managed by python's garbage collector.

Technically, it is a safe wrapper around the unsafe *mut ffi::PyObject pointer.

Methods

impl PyObject
[src]

Creates a PyObject instance for the given FFI pointer. This moves ownership over the pointer into the PyObject. Undefined behavior if the pointer is NULL or invalid.

Creates a PyObject instance for the given FFI pointer. Panics if the pointer is null. Undefined behavior if the pointer is invalid.

Construct PyObject from the result of a Python FFI call that returns a new reference (owned pointer). Returns Err(PyErr) if the pointer is null.

Construct PyObject from the result of a Python FFI call that returns a new reference (owned pointer). Returns None if the pointer is null.

Creates a PyObject instance for the given Python FFI pointer. Calls Py_INCREF() on the ptr. Undefined behavior if the pointer is NULL or invalid.

Creates a PyObject instance for the given Python FFI pointer. Calls Py_INCREF() on the ptr. Returns Err(PyErr) if the pointer is null.

Creates a PyObject instance for the given Python FFI pointer. Calls Py_INCREF() on the ptr. Returns None if the pointer is null.

Gets the reference count of the ffi::PyObject pointer.

Clone self, Calls Py_INCREF() on the ptr.

Returns whether the object is considered to be None. This is equivalent to the Python expression: 'is None'

Returns whether the object is considered to be true. This is equivalent to the Python expression: 'not not self'

Casts the PyObject to a concrete Python object type.

Extracts some type from the Python object. This is a wrapper function around FromPyObject::extract().

Retrieves an attribute value. This is equivalent to the Python expression 'self.attr_name'.

Calls the object. This is equivalent to the Python expression: 'self(*args, **kwargs)'

Calls the object without arguments. This is equivalent to the Python expression: 'self()'

Calls the object. This is equivalent to the Python expression: 'self(*args)'

Calls a method on the object. This is equivalent to the Python expression: 'self.name(*args, **kwargs)'

Calls a method on the object. This is equivalent to the Python expression: 'self.name()'

Calls a method on the object. This is equivalent to the Python expression: 'self.name(*args)'

Trait Implementations

impl ToPyObject for PyObject
[src]

impl IntoPyObject for PyObject
[src]

impl<'a> FromPyObject<'a> for PyObject
[src]

Extracts Self from the source PyObject.

impl AsPyRef<PyObjectRef> for PyObject
[src]

Acquire python gil and call closure with object reference.

Acquire python gil and call closure with mutable object reference.

impl ToPyPointer for PyObject
[src]

Gets the underlying FFI pointer, returns a borrowed pointer.

impl<'a> ToPyPointer for &'a PyObject
[src]

Gets the underlying FFI pointer, returns a borrowed pointer.

impl IntoPyPointer for PyObject
[src]

Gets the underlying FFI pointer, returns a owned pointer.

impl<T> From<Py<T>> for PyObject
[src]

impl<'a, T> From<&'a T> for PyObject where
    T: ToPyPointer
[src]

impl<'a, T> From<&'a mut T> for PyObject where
    T: ToPyPointer
[src]

impl Drop for PyObject
[src]

Dropping a PyObject instance decrements the reference count on the object by 1.

impl Sync for PyObject
[src]

impl PartialEq<PyObject> for PyObject
[src]

Checks for identity, not python's __eq__

This method tests for !=.

impl Send for PyObject
[src]

impl Debug for PyObject
[src]

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]