pub struct Py<T>(/* private fields */);
Expand description
A GIL-independent reference to an object allocated on the Python heap.
This type does not auto-dereference to the inner object because you must prove you hold the GIL to access it. Instead, call one of its methods to access the inner object:
Py::as_ref
, to borrow a GIL-bound reference to the contained object.Py::borrow
,Py::try_borrow
,Py::borrow_mut
, orPy::try_borrow_mut
, to get a (mutable) reference to a contained pyclass, using a scheme similar to std’sRefCell
. See thePyCell
guide entry for more information.- You can call methods directly on
Py
withPy::call
,Py::call_method
and friends. These require passing in thePython<'py>
token but are otherwise similar to the corresponding methods onPyAny
.
§Example: Storing Python objects in #[pyclass]
structs
Usually Bound<'py, T>
is recommended for interacting with Python objects as its lifetime 'py
is an association to the GIL and that enables many operations to be done as efficiently as possible.
However, #[pyclass]
structs cannot carry a lifetime, so Py<T>
is the only way to store
a Python object in a #[pyclass]
struct.
For example, this won’t compile:
#[pyclass]
struct Foo<'py> {
inner: Bound<'py, PyDict>,
}
impl Foo {
fn new() -> Foo {
let foo = Python::with_gil(|py| {
// `py` will only last for this scope.
// `Bound<'py, PyDict>` inherits the GIL lifetime from `py` and
// so won't be able to outlive this closure.
let dict: Bound<'_, PyDict> = PyDict::new_bound(py);
// because `Foo` contains `dict` its lifetime
// is now also tied to `py`.
Foo { inner: dict }
});
// Foo is no longer valid.
// Returning it from this function is a 💥 compiler error 💥
foo
}
}
Py
<T>
can be used to get around this by converting dict
into a GIL-independent reference:
use pyo3::prelude::*;
use pyo3::types::PyDict;
#[pyclass]
struct Foo {
inner: Py<PyDict>,
}
#[pymethods]
impl Foo {
#[new]
fn __new__() -> Foo {
Python::with_gil(|py| {
let dict: Py<PyDict> = PyDict::new_bound(py).unbind();
Foo { inner: dict }
})
}
}
This can also be done with other pyclasses:
use pyo3::prelude::*;
#[pyclass]
struct Bar {/* ... */}
#[pyclass]
struct Foo {
inner: Py<Bar>,
}
#[pymethods]
impl Foo {
#[new]
fn __new__() -> PyResult<Foo> {
Python::with_gil(|py| {
let bar: Py<Bar> = Py::new(py, Bar {})?;
Ok(Foo { inner: bar })
})
}
}
§Example: Shared ownership of Python objects
Py<T>
can be used to share ownership of a Python object, similar to std’s Rc
<T>
.
As with Rc
<T>
, cloning it increases its reference count rather than duplicating
the underlying object.
This can be done using either Py::clone_ref
or Py
<T>
’s Clone
trait implementation.
Py::clone_ref
will be faster if you happen to be already holding the GIL.
use pyo3::prelude::*;
use pyo3::types::PyDict;
Python::with_gil(|py| {
let first: Py<PyDict> = PyDict::new_bound(py).unbind();
// All of these are valid syntax
let second = Py::clone_ref(&first, py);
let third = first.clone_ref(py);
let fourth = Py::clone(&first);
let fifth = first.clone();
// Disposing of our original `Py<PyDict>` just decrements the reference count.
drop(first);
// They all point to the same object
assert!(second.is(&third));
assert!(fourth.is(&fifth));
assert!(second.is(&fourth));
});
§Preventing reference cycles
It is easy to accidentally create reference cycles using Py
<T>
.
The Python interpreter can break these reference cycles within pyclasses if they
integrate with the garbage collector. If your pyclass contains other Python
objects you should implement it to avoid leaking memory.
§A note on Python reference counts
Dropping a Py
<T>
will eventually decrease Python’s reference count
of the pointed-to variable, allowing Python’s garbage collector to free
the associated memory, but this may not happen immediately. This is
because a Py
<T>
can be dropped at any time, but the Python reference
count can only be modified when the GIL is held.
If a Py
<T>
is dropped while its thread happens to be holding the
GIL then the Python reference count will be decreased immediately.
Otherwise, the reference count will be decreased the next time the GIL is
reacquired.
If you happen to be already holding the GIL, Py::drop_ref
will decrease
the Python reference count immediately and will execute slightly faster than
relying on implicit Drop
s.
§A note on Send
and Sync
Accessing this object is threadsafe, since any access to its API requires a Python<'py>
token.
As you can only get this by acquiring the GIL, Py<...>
implements Send
and Sync
.
Implementations§
source§impl<T> Py<T>where
T: PyClass,
impl<T> Py<T>where
T: PyClass,
sourcepub fn new(
py: Python<'_>,
value: impl Into<PyClassInitializer<T>>
) -> PyResult<Py<T>>
pub fn new( py: Python<'_>, value: impl Into<PyClassInitializer<T>> ) -> PyResult<Py<T>>
Creates a new instance Py<T>
of a #[pyclass]
on the Python heap.
§Examples
use pyo3::prelude::*;
#[pyclass]
struct Foo {/* fields omitted */}
Python::with_gil(|py| -> PyResult<Py<Foo>> {
let foo: Py<Foo> = Py::new(py, Foo {})?;
Ok(foo)
})?;
source§impl<T> Py<T>where
T: HasPyGilRef,
impl<T> Py<T>where
T: HasPyGilRef,
sourcepub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py T::AsRefTarget
pub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py T::AsRefTarget
Borrows a GIL-bound reference to the contained T
.
By binding to the GIL lifetime, this allows the GIL-bound reference to not require
Python<'py>
for any of its methods, which makes calling methods
on it more ergonomic.
For native types, this reference is &T
. For pyclasses, this is &PyCell<T>
.
Note that the lifetime of the returned reference is the shortest of &self
and
Python<'py>
.
Consider using Py::into_ref
instead if this poses a problem.
§Examples
Get access to &PyList
from Py<PyList>
:
Python::with_gil(|py| {
let list: Py<PyList> = PyList::empty_bound(py).into();
let list: &PyList = list.as_ref(py);
assert_eq!(list.len(), 0);
});
Get access to &PyCell<MyClass>
from Py<MyClass>
:
#[pyclass]
struct MyClass {}
Python::with_gil(|py| {
let my_class: Py<MyClass> = Py::new(py, MyClass {}).unwrap();
let my_class_cell: &PyCell<MyClass> = my_class.as_ref(py);
assert!(my_class_cell.try_borrow().is_ok());
});
sourcepub fn into_ref(self, py: Python<'_>) -> &T::AsRefTarget
pub fn into_ref(self, py: Python<'_>) -> &T::AsRefTarget
Borrows a GIL-bound reference to the contained T
independently of the lifetime of T
.
This method is similar to as_ref
but consumes self
and registers the
Python object reference in PyO3’s object storage. The reference count for the Python
object will not be decreased until the GIL lifetime ends.
You should prefer using as_ref
if you can as it’ll have less overhead.
§Examples
Py::as_ref
’s lifetime limitation forbids creating a function that references a
variable created inside the function.
fn new_py_any<'py>(py: Python<'py>, value: impl IntoPy<Py<PyAny>>) -> &'py PyAny {
let obj: Py<PyAny> = value.into_py(py);
// The lifetime of the return value of this function is the shortest
// of `obj` and `py`. As `obj` is owned by the current function,
// Rust won't let the return value escape this function!
obj.as_ref(py)
}
This can be solved by using Py::into_ref
instead, which does not suffer from this issue.
Note that the lifetime of the Python<'py>
token is transferred to
the returned reference.
fn new_py_any<'py>(py: Python<'py>, value: impl IntoPy<Py<PyAny>>) -> &'py PyAny {
let obj: Py<PyAny> = value.into_py(py);
// This reference's lifetime is determined by `py`'s lifetime.
// Because that originates from outside this function,
// this return value is allowed.
obj.into_ref(py)
}
source§impl<T> Py<T>
impl<T> Py<T>
sourcepub fn as_ptr(&self) -> *mut PyObject
pub fn as_ptr(&self) -> *mut PyObject
Returns the raw FFI pointer represented by self.
§Safety
Callers are responsible for ensuring that the pointer does not outlive self.
The reference is borrowed; callers should not decrease the reference count when they are finished with the pointer.
source§impl<T> Py<T>where
T: PyClass,
impl<T> Py<T>where
T: PyClass,
sourcepub fn borrow<'py>(&'py self, py: Python<'py>) -> PyRef<'py, T>
pub fn borrow<'py>(&'py self, py: Python<'py>) -> PyRef<'py, T>
Immutably borrows the value T
.
This borrow lasts while the returned PyRef
exists.
Multiple immutable borrows can be taken out at the same time.
For frozen classes, the simpler get
is available.
Equivalent to self.as_ref(py).borrow()
-
see PyCell::borrow
.
§Examples
#[pyclass]
struct Foo {
inner: u8,
}
Python::with_gil(|py| -> PyResult<()> {
let foo: Py<Foo> = Py::new(py, Foo { inner: 73 })?;
let inner: &u8 = &foo.borrow(py).inner;
assert_eq!(*inner, 73);
Ok(())
})?;
§Panics
Panics if the value is currently mutably borrowed. For a non-panicking variant, use
try_borrow
.
sourcepub fn borrow_mut<'py>(&'py self, py: Python<'py>) -> PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
pub fn borrow_mut<'py>(&'py self, py: Python<'py>) -> PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
Mutably borrows the value T
.
This borrow lasts while the returned PyRefMut
exists.
Equivalent to self.as_ref(py).borrow_mut()
-
see PyCell::borrow_mut
.
§Examples
#[pyclass]
struct Foo {
inner: u8,
}
Python::with_gil(|py| -> PyResult<()> {
let foo: Py<Foo> = Py::new(py, Foo { inner: 73 })?;
foo.borrow_mut(py).inner = 35;
assert_eq!(foo.borrow(py).inner, 35);
Ok(())
})?;
§Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut
.
sourcepub fn try_borrow<'py>(
&'py self,
py: Python<'py>
) -> Result<PyRef<'py, T>, PyBorrowError>
pub fn try_borrow<'py>( &'py self, py: Python<'py> ) -> Result<PyRef<'py, T>, PyBorrowError>
Attempts to immutably borrow the value T
, returning an error if the value is currently mutably borrowed.
The borrow lasts while the returned PyRef
exists.
This is the non-panicking variant of borrow
.
For frozen classes, the simpler get
is available.
Equivalent to self.as_ref(py).borrow_mut()
-
see PyCell::try_borrow
.
sourcepub fn try_borrow_mut<'py>(
&'py self,
py: Python<'py>
) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
T: PyClass<Frozen = False>,
pub fn try_borrow_mut<'py>(
&'py self,
py: Python<'py>
) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
T: PyClass<Frozen = False>,
Attempts to mutably borrow the value T
, returning an error if the value is currently borrowed.
The borrow lasts while the returned PyRefMut
exists.
This is the non-panicking variant of borrow_mut
.
Equivalent to self.as_ref(py).try_borrow_mut()
-
see PyCell::try_borrow_mut
.
sourcepub fn get(&self) -> &T
pub fn get(&self) -> &T
Provide an immutable borrow of the value T
without acquiring the GIL.
This is available if the class is frozen
and Sync
.
§Examples
use std::sync::atomic::{AtomicUsize, Ordering};
#[pyclass(frozen)]
struct FrozenCounter {
value: AtomicUsize,
}
let cell = Python::with_gil(|py| {
let counter = FrozenCounter { value: AtomicUsize::new(0) };
Py::new(py, counter).unwrap()
});
cell.get().value.fetch_add(1, Ordering::Relaxed);
source§impl<T> Py<T>
impl<T> Py<T>
sourcepub fn bind<'py>(&self, _py: Python<'py>) -> &Bound<'py, T>
pub fn bind<'py>(&self, _py: Python<'py>) -> &Bound<'py, T>
Attaches this Py
to the given Python context, allowing access to further Python APIs.
sourcepub fn into_bound(self, py: Python<'_>) -> Bound<'_, T>
pub fn into_bound(self, py: Python<'_>) -> Bound<'_, T>
Same as bind
but takes ownership of self
.
sourcepub fn bind_borrowed<'a, 'py>(&'a self, py: Python<'py>) -> Borrowed<'a, 'py, T>
pub fn bind_borrowed<'a, 'py>(&'a self, py: Python<'py>) -> Borrowed<'a, 'py, T>
Same as bind
but produces a Borrowed<T>
instead of a Bound<T>
.
sourcepub fn is<U: AsPyPointer>(&self, o: &U) -> bool
pub fn is<U: AsPyPointer>(&self, o: &U) -> bool
Returns whether self
and other
point to the same object. To compare
the equality of two objects (the ==
operator), use eq
.
This is equivalent to the Python expression self is other
.
sourcepub fn get_refcnt(&self, _py: Python<'_>) -> isize
pub fn get_refcnt(&self, _py: Python<'_>) -> isize
Gets the reference count of the ffi::PyObject
pointer.
sourcepub fn clone_ref(&self, py: Python<'_>) -> Py<T>
pub fn clone_ref(&self, py: Python<'_>) -> Py<T>
Makes a clone of self
.
This creates another pointer to the same object, increasing its reference count.
You should prefer using this method over Clone
if you happen to be holding the GIL already.
§Examples
use pyo3::prelude::*;
use pyo3::types::PyDict;
Python::with_gil(|py| {
let first: Py<PyDict> = PyDict::new_bound(py).unbind();
let second = Py::clone_ref(&first, py);
// Both point to the same object
assert!(first.is(&second));
});
sourcepub fn drop_ref(self, py: Python<'_>)
pub fn drop_ref(self, py: Python<'_>)
Drops self
and immediately decreases its reference count.
This method is a micro-optimisation over Drop
if you happen to be holding the GIL
already.
Note that if you are using Bound
, you do not need to use Self::drop_ref
since
Bound
guarantees that the GIL is held.
§Examples
use pyo3::prelude::*;
use pyo3::types::PyDict;
Python::with_gil(|py| {
let object: Py<PyDict> = PyDict::new_bound(py).unbind();
// some usage of object
object.drop_ref(py);
});
sourcepub fn is_none(&self, _py: Python<'_>) -> bool
pub fn is_none(&self, _py: Python<'_>) -> bool
Returns whether the object is considered to be None.
This is equivalent to the Python expression self is None
.
sourcepub fn is_ellipsis(&self) -> bool
👎Deprecated since 0.20.0: use .is(py.Ellipsis())
instead
pub fn is_ellipsis(&self) -> bool
.is(py.Ellipsis())
insteadReturns whether the object is Ellipsis, e.g. ...
.
This is equivalent to the Python expression self is ...
.
sourcepub fn is_true(&self, py: Python<'_>) -> PyResult<bool>
👎Deprecated since 0.21.0: use .is_truthy()
instead
pub fn is_true(&self, py: Python<'_>) -> PyResult<bool>
.is_truthy()
insteadReturns whether the object is considered to be true.
This is equivalent to the Python expression bool(self)
.
sourcepub fn is_truthy(&self, py: Python<'_>) -> PyResult<bool>
pub fn is_truthy(&self, py: Python<'_>) -> PyResult<bool>
Returns whether the object is considered to be true.
This applies truth value testing equivalent to the Python expression bool(self)
.
sourcepub fn extract<'a, 'py, D>(&'a self, py: Python<'py>) -> PyResult<D>where
D: FromPyObjectBound<'a, 'py>,
'py: 'a,
pub fn extract<'a, 'py, D>(&'a self, py: Python<'py>) -> PyResult<D>where
D: FromPyObjectBound<'a, 'py>,
'py: 'a,
Extracts some type from the Python object.
This is a wrapper function around FromPyObject::extract()
.
sourcepub fn getattr<N>(&self, py: Python<'_>, attr_name: N) -> PyResult<PyObject>
pub fn getattr<N>(&self, py: Python<'_>, attr_name: N) -> PyResult<PyObject>
Retrieves an attribute value.
This is equivalent to the Python expression self.attr_name
.
If calling this method becomes performance-critical, the intern!
macro
can be used to intern attr_name
, thereby avoiding repeated temporary allocations of
Python strings.
§Example: intern!
ing the attribute name
#[pyfunction]
fn version(sys: Py<PyModule>, py: Python<'_>) -> PyResult<PyObject> {
sys.getattr(py, intern!(py, "version"))
}
sourcepub fn setattr<N, V>(
&self,
py: Python<'_>,
attr_name: N,
value: V
) -> PyResult<()>
pub fn setattr<N, V>( &self, py: Python<'_>, attr_name: N, value: V ) -> PyResult<()>
Sets an attribute value.
This is equivalent to the Python expression self.attr_name = value
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern attr_name
.
§Example: intern!
ing the attribute name
#[pyfunction]
fn set_answer(ob: PyObject, py: Python<'_>) -> PyResult<()> {
ob.setattr(py, intern!(py, "answer"), 42)
}
sourcepub fn call<A>(
&self,
py: Python<'_>,
args: A,
kwargs: Option<&PyDict>
) -> PyResult<PyObject>
pub fn call<A>( &self, py: Python<'_>, args: A, kwargs: Option<&PyDict> ) -> PyResult<PyObject>
Deprecated form of call_bound
.
sourcepub fn call_bound(
&self,
py: Python<'_>,
args: impl IntoPy<Py<PyTuple>>,
kwargs: Option<&Bound<'_, PyDict>>
) -> PyResult<PyObject>
pub fn call_bound( &self, py: Python<'_>, args: impl IntoPy<Py<PyTuple>>, kwargs: Option<&Bound<'_, PyDict>> ) -> PyResult<PyObject>
Calls the object.
This is equivalent to the Python expression self(*args, **kwargs)
.
sourcepub fn call1(
&self,
py: Python<'_>,
args: impl IntoPy<Py<PyTuple>>
) -> PyResult<PyObject>
pub fn call1( &self, py: Python<'_>, args: impl IntoPy<Py<PyTuple>> ) -> PyResult<PyObject>
Calls the object with only positional arguments.
This is equivalent to the Python expression self(*args)
.
sourcepub fn call0(&self, py: Python<'_>) -> PyResult<PyObject>
pub fn call0(&self, py: Python<'_>) -> PyResult<PyObject>
Calls the object without arguments.
This is equivalent to the Python expression self()
.
sourcepub fn call_method<N, A>(
&self,
py: Python<'_>,
name: N,
args: A,
kwargs: Option<&PyDict>
) -> PyResult<PyObject>
pub fn call_method<N, A>( &self, py: Python<'_>, name: N, args: A, kwargs: Option<&PyDict> ) -> PyResult<PyObject>
Deprecated form of call_method_bound
.
sourcepub fn call_method_bound<N, A>(
&self,
py: Python<'_>,
name: N,
args: A,
kwargs: Option<&Bound<'_, PyDict>>
) -> PyResult<PyObject>
pub fn call_method_bound<N, A>( &self, py: Python<'_>, name: N, args: A, kwargs: Option<&Bound<'_, PyDict>> ) -> PyResult<PyObject>
Calls a method on the object.
This is equivalent to the Python expression self.name(*args, **kwargs)
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern name
.
sourcepub fn call_method1<N, A>(
&self,
py: Python<'_>,
name: N,
args: A
) -> PyResult<PyObject>
pub fn call_method1<N, A>( &self, py: Python<'_>, name: N, args: A ) -> PyResult<PyObject>
Calls a method on the object with only positional arguments.
This is equivalent to the Python expression self.name(*args)
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern name
.
sourcepub fn call_method0<N>(&self, py: Python<'_>, name: N) -> PyResult<PyObject>
pub fn call_method0<N>(&self, py: Python<'_>, name: N) -> PyResult<PyObject>
Calls a method on the object with no arguments.
This is equivalent to the Python expression self.name()
.
To avoid repeated temporary allocations of Python strings, the intern!
macro can be used to intern name
.
sourcepub unsafe fn from_owned_ptr_or_opt(
_py: Python<'_>,
ptr: *mut PyObject
) -> Option<Self>
pub unsafe fn from_owned_ptr_or_opt( _py: Python<'_>, ptr: *mut PyObject ) -> Option<Self>
Create a Py<T>
instance by taking ownership of the given FFI pointer.
If ptr
is null then None
is returned.
§Safety
If non-null, ptr
must be a pointer to a Python object of type T.
sourcepub unsafe fn from_borrowed_ptr_or_err(
py: Python<'_>,
ptr: *mut PyObject
) -> PyResult<Self>
pub unsafe fn from_borrowed_ptr_or_err( py: Python<'_>, ptr: *mut PyObject ) -> PyResult<Self>
Create a Py<T>
instance by creating a new reference from the given FFI pointer.
If ptr
is null then the current Python exception is fetched as a PyErr
.
§Safety
ptr
must be a pointer to a Python object of type T.
source§impl Py<PyAny>
impl Py<PyAny>
sourcepub fn downcast<'py, T>(
&'py self,
py: Python<'py>
) -> Result<&'py T, PyDowncastError<'py>>where
T: PyTypeCheck<AsRefTarget = T>,
pub fn downcast<'py, T>(
&'py self,
py: Python<'py>
) -> Result<&'py T, PyDowncastError<'py>>where
T: PyTypeCheck<AsRefTarget = T>,
Deprecated form of PyObject::downcast_bound
sourcepub fn downcast_bound<'py, T>(
&self,
py: Python<'py>
) -> Result<&Bound<'py, T>, DowncastError<'_, 'py>>where
T: PyTypeCheck,
pub fn downcast_bound<'py, T>(
&self,
py: Python<'py>
) -> Result<&Bound<'py, T>, DowncastError<'_, 'py>>where
T: PyTypeCheck,
Downcast this PyObject
to a concrete Python type or pyclass.
Note that you can often avoid downcasting yourself by just specifying the desired type in function or method signatures. However, manual downcasting is sometimes necessary.
For extracting a Rust-only type, see Py::extract
.
§Example: Downcasting to a specific Python object
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyList};
Python::with_gil(|py| {
let any: PyObject = PyDict::new_bound(py).into();
assert!(any.downcast_bound::<PyDict>(py).is_ok());
assert!(any.downcast_bound::<PyList>(py).is_err());
});
§Example: Getting a reference to a pyclass
This is useful if you want to mutate a PyObject
that
might actually be a pyclass.
use pyo3::prelude::*;
#[pyclass]
struct Class {
i: i32,
}
Python::with_gil(|py| {
let class: PyObject = Py::new(py, Class { i: 0 }).unwrap().into_py(py);
let class_bound = class.downcast_bound::<Class>(py)?;
class_bound.borrow_mut().i += 1;
// Alternatively you can get a `PyRefMut` directly
let class_ref: PyRefMut<'_, Class> = class.extract(py)?;
assert_eq!(class_ref.i, 1);
Ok(())
})
sourcepub unsafe fn downcast_unchecked<'py, T>(&'py self, py: Python<'py>) -> &Twhere
T: HasPyGilRef<AsRefTarget = T>,
pub unsafe fn downcast_unchecked<'py, T>(&'py self, py: Python<'py>) -> &Twhere
T: HasPyGilRef<AsRefTarget = T>,
Deprecated form of PyObject::downcast_bound_unchecked
§Safety
Callers must ensure that the type is valid or risk type confusion.
sourcepub unsafe fn downcast_bound_unchecked<'py, T>(
&self,
py: Python<'py>
) -> &Bound<'py, T>
pub unsafe fn downcast_bound_unchecked<'py, T>( &self, py: Python<'py> ) -> &Bound<'py, T>
Casts the PyObject to a concrete Python object type without checking validity.
§Safety
Callers must ensure that the type is valid or risk type confusion.
source§impl Py<PyString>
impl Py<PyString>
sourcepub fn to_str<'a>(&'a self, py: Python<'_>) -> PyResult<&'a str>
Available on Py_3_10
or non-Py_LIMITED_API
only.
pub fn to_str<'a>(&'a self, py: Python<'_>) -> PyResult<&'a str>
Py_3_10
or non-Py_LIMITED_API
only.Gets the Python string as a Rust UTF-8 string slice.
Returns a UnicodeEncodeError
if the input is not valid unicode
(containing unpaired surrogates).
Because str
objects are immutable, the returned slice is independent of
the GIL lifetime.
sourcepub fn to_cow<'a>(&'a self, py: Python<'_>) -> PyResult<Cow<'a, str>>
pub fn to_cow<'a>(&'a self, py: Python<'_>) -> PyResult<Cow<'a, str>>
Converts the PyString
into a Rust string, avoiding copying when possible.
Returns a UnicodeEncodeError
if the input is not valid unicode
(containing unpaired surrogates).
Because str
objects are immutable, the returned slice is independent of
the GIL lifetime.
sourcepub fn to_string_lossy<'a>(&'a self, py: Python<'_>) -> Cow<'a, str>
pub fn to_string_lossy<'a>(&'a self, py: Python<'_>) -> Cow<'a, str>
Converts the PyString
into a Rust string.
Unpaired surrogates invalid UTF-8 sequences are
replaced with U+FFFD REPLACEMENT CHARACTER
.
Because str
objects are immutable, the returned slice is independent of
the GIL lifetime.
Trait Implementations§
source§impl<T> AsPyPointer for Py<T>
impl<T> AsPyPointer for Py<T>
source§impl<T> Clone for Py<T>
impl<T> Clone for Py<T>
If the GIL is held this increments self
’s reference count.
Otherwise this registers the Py
<T>
instance to have its reference count
incremented the next time PyO3 acquires the GIL.
source§impl<'de, T> Deserialize<'de> for Py<T>
Available on crate feature serde
only.
impl<'de, T> Deserialize<'de> for Py<T>
serde
only.source§fn deserialize<D>(deserializer: D) -> Result<Py<T>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Py<T>, D::Error>where
D: Deserializer<'de>,
source§impl<T> Drop for Py<T>
impl<T> Drop for Py<T>
Dropping a Py
instance decrements the reference count on the object by 1.
source§impl<T> Error for Py<T>
impl<T> Error for Py<T>
Py<T>
can be used as an error when T is an Error.
However for GIL lifetime reasons, cause() cannot be implemented for Py<T>
.
Use .as_ref() to get the GIL-scoped error if you need to inspect the cause.
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl From<&CancelledError> for Py<CancelledError>
impl From<&CancelledError> for Py<CancelledError>
source§fn from(other: &CancelledError) -> Self
fn from(other: &CancelledError) -> Self
source§impl From<&IncompleteReadError> for Py<IncompleteReadError>
impl From<&IncompleteReadError> for Py<IncompleteReadError>
source§fn from(other: &IncompleteReadError) -> Self
fn from(other: &IncompleteReadError) -> Self
source§impl From<&InvalidStateError> for Py<InvalidStateError>
impl From<&InvalidStateError> for Py<InvalidStateError>
source§fn from(other: &InvalidStateError) -> Self
fn from(other: &InvalidStateError) -> Self
source§impl From<&LimitOverrunError> for Py<LimitOverrunError>
impl From<&LimitOverrunError> for Py<LimitOverrunError>
source§fn from(other: &LimitOverrunError) -> Self
fn from(other: &LimitOverrunError) -> Self
source§impl From<&PanicException> for Py<PanicException>
impl From<&PanicException> for Py<PanicException>
source§fn from(other: &PanicException) -> Self
fn from(other: &PanicException) -> Self
source§impl From<&PyArithmeticError> for Py<PyArithmeticError>
impl From<&PyArithmeticError> for Py<PyArithmeticError>
source§fn from(other: &PyArithmeticError) -> Self
fn from(other: &PyArithmeticError) -> Self
source§impl From<&PyAssertionError> for Py<PyAssertionError>
impl From<&PyAssertionError> for Py<PyAssertionError>
source§fn from(other: &PyAssertionError) -> Self
fn from(other: &PyAssertionError) -> Self
source§impl From<&PyAttributeError> for Py<PyAttributeError>
impl From<&PyAttributeError> for Py<PyAttributeError>
source§fn from(other: &PyAttributeError) -> Self
fn from(other: &PyAttributeError) -> Self
source§impl From<&PyBaseException> for Py<PyBaseException>
impl From<&PyBaseException> for Py<PyBaseException>
source§fn from(other: &PyBaseException) -> Self
fn from(other: &PyBaseException) -> Self
source§impl From<&PyBlockingIOError> for Py<PyBlockingIOError>
impl From<&PyBlockingIOError> for Py<PyBlockingIOError>
source§fn from(other: &PyBlockingIOError) -> Self
fn from(other: &PyBlockingIOError) -> Self
source§impl From<&PyBrokenPipeError> for Py<PyBrokenPipeError>
impl From<&PyBrokenPipeError> for Py<PyBrokenPipeError>
source§fn from(other: &PyBrokenPipeError) -> Self
fn from(other: &PyBrokenPipeError) -> Self
source§impl From<&PyBufferError> for Py<PyBufferError>
impl From<&PyBufferError> for Py<PyBufferError>
source§fn from(other: &PyBufferError) -> Self
fn from(other: &PyBufferError) -> Self
source§impl From<&PyByteArray> for Py<PyByteArray>
impl From<&PyByteArray> for Py<PyByteArray>
source§fn from(other: &PyByteArray) -> Self
fn from(other: &PyByteArray) -> Self
source§impl From<&PyBytesWarning> for Py<PyBytesWarning>
impl From<&PyBytesWarning> for Py<PyBytesWarning>
source§fn from(other: &PyBytesWarning) -> Self
fn from(other: &PyBytesWarning) -> Self
source§impl From<&PyCFunction> for Py<PyCFunction>
impl From<&PyCFunction> for Py<PyCFunction>
source§fn from(other: &PyCFunction) -> Self
fn from(other: &PyCFunction) -> Self
source§impl From<&PyChildProcessError> for Py<PyChildProcessError>
impl From<&PyChildProcessError> for Py<PyChildProcessError>
source§fn from(other: &PyChildProcessError) -> Self
fn from(other: &PyChildProcessError) -> Self
source§impl From<&PyCode> for Py<PyCode>
Available on non-Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.
impl From<&PyCode> for Py<PyCode>
Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.source§impl From<&PyConnectionAbortedError> for Py<PyConnectionAbortedError>
impl From<&PyConnectionAbortedError> for Py<PyConnectionAbortedError>
source§fn from(other: &PyConnectionAbortedError) -> Self
fn from(other: &PyConnectionAbortedError) -> Self
source§impl From<&PyConnectionError> for Py<PyConnectionError>
impl From<&PyConnectionError> for Py<PyConnectionError>
source§fn from(other: &PyConnectionError) -> Self
fn from(other: &PyConnectionError) -> Self
source§impl From<&PyConnectionRefusedError> for Py<PyConnectionRefusedError>
impl From<&PyConnectionRefusedError> for Py<PyConnectionRefusedError>
source§fn from(other: &PyConnectionRefusedError) -> Self
fn from(other: &PyConnectionRefusedError) -> Self
source§impl From<&PyConnectionResetError> for Py<PyConnectionResetError>
impl From<&PyConnectionResetError> for Py<PyConnectionResetError>
source§fn from(other: &PyConnectionResetError) -> Self
fn from(other: &PyConnectionResetError) -> Self
source§impl From<&PyDateTime> for Py<PyDateTime>
Available on non-Py_LIMITED_API
only.
impl From<&PyDateTime> for Py<PyDateTime>
Py_LIMITED_API
only.source§fn from(other: &PyDateTime) -> Self
fn from(other: &PyDateTime) -> Self
source§impl From<&PyDeprecationWarning> for Py<PyDeprecationWarning>
impl From<&PyDeprecationWarning> for Py<PyDeprecationWarning>
source§fn from(other: &PyDeprecationWarning) -> Self
fn from(other: &PyDeprecationWarning) -> Self
source§impl From<&PyDictItems> for Py<PyDictItems>
impl From<&PyDictItems> for Py<PyDictItems>
source§fn from(other: &PyDictItems) -> Self
fn from(other: &PyDictItems) -> Self
source§impl From<&PyDictKeys> for Py<PyDictKeys>
impl From<&PyDictKeys> for Py<PyDictKeys>
source§fn from(other: &PyDictKeys) -> Self
fn from(other: &PyDictKeys) -> Self
source§impl From<&PyDictValues> for Py<PyDictValues>
impl From<&PyDictValues> for Py<PyDictValues>
source§fn from(other: &PyDictValues) -> Self
fn from(other: &PyDictValues) -> Self
source§impl From<&PyEOFError> for Py<PyEOFError>
impl From<&PyEOFError> for Py<PyEOFError>
source§fn from(other: &PyEOFError) -> Self
fn from(other: &PyEOFError) -> Self
source§impl From<&PyEllipsis> for Py<PyEllipsis>
impl From<&PyEllipsis> for Py<PyEllipsis>
source§fn from(other: &PyEllipsis) -> Self
fn from(other: &PyEllipsis) -> Self
source§impl From<&PyEncodingWarning> for Py<PyEncodingWarning>
impl From<&PyEncodingWarning> for Py<PyEncodingWarning>
source§fn from(other: &PyEncodingWarning) -> Self
fn from(other: &PyEncodingWarning) -> Self
source§impl From<&PyEnvironmentError> for Py<PyEnvironmentError>
impl From<&PyEnvironmentError> for Py<PyEnvironmentError>
source§fn from(other: &PyEnvironmentError) -> Self
fn from(other: &PyEnvironmentError) -> Self
source§impl From<&PyException> for Py<PyException>
impl From<&PyException> for Py<PyException>
source§fn from(other: &PyException) -> Self
fn from(other: &PyException) -> Self
source§impl From<&PyFileExistsError> for Py<PyFileExistsError>
impl From<&PyFileExistsError> for Py<PyFileExistsError>
source§fn from(other: &PyFileExistsError) -> Self
fn from(other: &PyFileExistsError) -> Self
source§impl From<&PyFileNotFoundError> for Py<PyFileNotFoundError>
impl From<&PyFileNotFoundError> for Py<PyFileNotFoundError>
source§fn from(other: &PyFileNotFoundError) -> Self
fn from(other: &PyFileNotFoundError) -> Self
source§impl From<&PyFloatingPointError> for Py<PyFloatingPointError>
impl From<&PyFloatingPointError> for Py<PyFloatingPointError>
source§fn from(other: &PyFloatingPointError) -> Self
fn from(other: &PyFloatingPointError) -> Self
source§impl From<&PyFrame> for Py<PyFrame>
Available on non-Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.
impl From<&PyFrame> for Py<PyFrame>
Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.source§impl From<&PyFrozenSet> for Py<PyFrozenSet>
impl From<&PyFrozenSet> for Py<PyFrozenSet>
source§fn from(other: &PyFrozenSet) -> Self
fn from(other: &PyFrozenSet) -> Self
source§impl From<&PyFunction> for Py<PyFunction>
impl From<&PyFunction> for Py<PyFunction>
source§fn from(other: &PyFunction) -> Self
fn from(other: &PyFunction) -> Self
source§impl From<&PyFutureWarning> for Py<PyFutureWarning>
impl From<&PyFutureWarning> for Py<PyFutureWarning>
source§fn from(other: &PyFutureWarning) -> Self
fn from(other: &PyFutureWarning) -> Self
source§impl From<&PyGeneratorExit> for Py<PyGeneratorExit>
impl From<&PyGeneratorExit> for Py<PyGeneratorExit>
source§fn from(other: &PyGeneratorExit) -> Self
fn from(other: &PyGeneratorExit) -> Self
source§impl From<&PyImportError> for Py<PyImportError>
impl From<&PyImportError> for Py<PyImportError>
source§fn from(other: &PyImportError) -> Self
fn from(other: &PyImportError) -> Self
source§impl From<&PyImportWarning> for Py<PyImportWarning>
impl From<&PyImportWarning> for Py<PyImportWarning>
source§fn from(other: &PyImportWarning) -> Self
fn from(other: &PyImportWarning) -> Self
source§impl From<&PyIndexError> for Py<PyIndexError>
impl From<&PyIndexError> for Py<PyIndexError>
source§fn from(other: &PyIndexError) -> Self
fn from(other: &PyIndexError) -> Self
source§impl From<&PyInterruptedError> for Py<PyInterruptedError>
impl From<&PyInterruptedError> for Py<PyInterruptedError>
source§fn from(other: &PyInterruptedError) -> Self
fn from(other: &PyInterruptedError) -> Self
source§impl From<&PyIsADirectoryError> for Py<PyIsADirectoryError>
impl From<&PyIsADirectoryError> for Py<PyIsADirectoryError>
source§fn from(other: &PyIsADirectoryError) -> Self
fn from(other: &PyIsADirectoryError) -> Self
source§impl From<&PyIterator> for Py<PyIterator>
impl From<&PyIterator> for Py<PyIterator>
source§fn from(other: &PyIterator) -> Self
fn from(other: &PyIterator) -> Self
source§impl From<&PyKeyError> for Py<PyKeyError>
impl From<&PyKeyError> for Py<PyKeyError>
source§fn from(other: &PyKeyError) -> Self
fn from(other: &PyKeyError) -> Self
source§impl From<&PyKeyboardInterrupt> for Py<PyKeyboardInterrupt>
impl From<&PyKeyboardInterrupt> for Py<PyKeyboardInterrupt>
source§fn from(other: &PyKeyboardInterrupt) -> Self
fn from(other: &PyKeyboardInterrupt) -> Self
source§impl From<&PyLookupError> for Py<PyLookupError>
impl From<&PyLookupError> for Py<PyLookupError>
source§fn from(other: &PyLookupError) -> Self
fn from(other: &PyLookupError) -> Self
source§impl From<&PyMemoryError> for Py<PyMemoryError>
impl From<&PyMemoryError> for Py<PyMemoryError>
source§fn from(other: &PyMemoryError) -> Self
fn from(other: &PyMemoryError) -> Self
source§impl From<&PyMemoryView> for Py<PyMemoryView>
impl From<&PyMemoryView> for Py<PyMemoryView>
source§fn from(other: &PyMemoryView) -> Self
fn from(other: &PyMemoryView) -> Self
source§impl From<&PyModuleNotFoundError> for Py<PyModuleNotFoundError>
impl From<&PyModuleNotFoundError> for Py<PyModuleNotFoundError>
source§fn from(other: &PyModuleNotFoundError) -> Self
fn from(other: &PyModuleNotFoundError) -> Self
source§impl From<&PyNameError> for Py<PyNameError>
impl From<&PyNameError> for Py<PyNameError>
source§fn from(other: &PyNameError) -> Self
fn from(other: &PyNameError) -> Self
source§impl From<&PyNotADirectoryError> for Py<PyNotADirectoryError>
impl From<&PyNotADirectoryError> for Py<PyNotADirectoryError>
source§fn from(other: &PyNotADirectoryError) -> Self
fn from(other: &PyNotADirectoryError) -> Self
source§impl From<&PyNotImplemented> for Py<PyNotImplemented>
impl From<&PyNotImplemented> for Py<PyNotImplemented>
source§fn from(other: &PyNotImplemented) -> Self
fn from(other: &PyNotImplemented) -> Self
source§impl From<&PyNotImplementedError> for Py<PyNotImplementedError>
impl From<&PyNotImplementedError> for Py<PyNotImplementedError>
source§fn from(other: &PyNotImplementedError) -> Self
fn from(other: &PyNotImplementedError) -> Self
source§impl From<&PyOverflowError> for Py<PyOverflowError>
impl From<&PyOverflowError> for Py<PyOverflowError>
source§fn from(other: &PyOverflowError) -> Self
fn from(other: &PyOverflowError) -> Self
source§impl From<&PyPendingDeprecationWarning> for Py<PyPendingDeprecationWarning>
impl From<&PyPendingDeprecationWarning> for Py<PyPendingDeprecationWarning>
source§fn from(other: &PyPendingDeprecationWarning) -> Self
fn from(other: &PyPendingDeprecationWarning) -> Self
source§impl From<&PyPermissionError> for Py<PyPermissionError>
impl From<&PyPermissionError> for Py<PyPermissionError>
source§fn from(other: &PyPermissionError) -> Self
fn from(other: &PyPermissionError) -> Self
source§impl From<&PyProcessLookupError> for Py<PyProcessLookupError>
impl From<&PyProcessLookupError> for Py<PyProcessLookupError>
source§fn from(other: &PyProcessLookupError) -> Self
fn from(other: &PyProcessLookupError) -> Self
source§impl From<&PyRecursionError> for Py<PyRecursionError>
impl From<&PyRecursionError> for Py<PyRecursionError>
source§fn from(other: &PyRecursionError) -> Self
fn from(other: &PyRecursionError) -> Self
source§impl From<&PyReferenceError> for Py<PyReferenceError>
impl From<&PyReferenceError> for Py<PyReferenceError>
source§fn from(other: &PyReferenceError) -> Self
fn from(other: &PyReferenceError) -> Self
source§impl From<&PyResourceWarning> for Py<PyResourceWarning>
impl From<&PyResourceWarning> for Py<PyResourceWarning>
source§fn from(other: &PyResourceWarning) -> Self
fn from(other: &PyResourceWarning) -> Self
source§impl From<&PyRuntimeError> for Py<PyRuntimeError>
impl From<&PyRuntimeError> for Py<PyRuntimeError>
source§fn from(other: &PyRuntimeError) -> Self
fn from(other: &PyRuntimeError) -> Self
source§impl From<&PyRuntimeWarning> for Py<PyRuntimeWarning>
impl From<&PyRuntimeWarning> for Py<PyRuntimeWarning>
source§fn from(other: &PyRuntimeWarning) -> Self
fn from(other: &PyRuntimeWarning) -> Self
source§impl From<&PySequence> for Py<PySequence>
impl From<&PySequence> for Py<PySequence>
source§fn from(other: &PySequence) -> Self
fn from(other: &PySequence) -> Self
source§impl From<&PyStopAsyncIteration> for Py<PyStopAsyncIteration>
impl From<&PyStopAsyncIteration> for Py<PyStopAsyncIteration>
source§fn from(other: &PyStopAsyncIteration) -> Self
fn from(other: &PyStopAsyncIteration) -> Self
source§impl From<&PyStopIteration> for Py<PyStopIteration>
impl From<&PyStopIteration> for Py<PyStopIteration>
source§fn from(other: &PyStopIteration) -> Self
fn from(other: &PyStopIteration) -> Self
source§impl From<&PySyntaxError> for Py<PySyntaxError>
impl From<&PySyntaxError> for Py<PySyntaxError>
source§fn from(other: &PySyntaxError) -> Self
fn from(other: &PySyntaxError) -> Self
source§impl From<&PySyntaxWarning> for Py<PySyntaxWarning>
impl From<&PySyntaxWarning> for Py<PySyntaxWarning>
source§fn from(other: &PySyntaxWarning) -> Self
fn from(other: &PySyntaxWarning) -> Self
source§impl From<&PySystemError> for Py<PySystemError>
impl From<&PySystemError> for Py<PySystemError>
source§fn from(other: &PySystemError) -> Self
fn from(other: &PySystemError) -> Self
source§impl From<&PySystemExit> for Py<PySystemExit>
impl From<&PySystemExit> for Py<PySystemExit>
source§fn from(other: &PySystemExit) -> Self
fn from(other: &PySystemExit) -> Self
source§impl From<&PyTimeoutError> for Py<PyTimeoutError>
impl From<&PyTimeoutError> for Py<PyTimeoutError>
source§fn from(other: &PyTimeoutError) -> Self
fn from(other: &PyTimeoutError) -> Self
source§impl From<&PyTraceback> for Py<PyTraceback>
impl From<&PyTraceback> for Py<PyTraceback>
source§fn from(other: &PyTraceback) -> Self
fn from(other: &PyTraceback) -> Self
source§impl From<&PyTypeError> for Py<PyTypeError>
impl From<&PyTypeError> for Py<PyTypeError>
source§fn from(other: &PyTypeError) -> Self
fn from(other: &PyTypeError) -> Self
source§impl From<&PyUnboundLocalError> for Py<PyUnboundLocalError>
impl From<&PyUnboundLocalError> for Py<PyUnboundLocalError>
source§fn from(other: &PyUnboundLocalError) -> Self
fn from(other: &PyUnboundLocalError) -> Self
source§impl From<&PyUnicodeDecodeError> for Py<PyUnicodeDecodeError>
impl From<&PyUnicodeDecodeError> for Py<PyUnicodeDecodeError>
source§fn from(other: &PyUnicodeDecodeError) -> Self
fn from(other: &PyUnicodeDecodeError) -> Self
source§impl From<&PyUnicodeEncodeError> for Py<PyUnicodeEncodeError>
impl From<&PyUnicodeEncodeError> for Py<PyUnicodeEncodeError>
source§fn from(other: &PyUnicodeEncodeError) -> Self
fn from(other: &PyUnicodeEncodeError) -> Self
source§impl From<&PyUnicodeError> for Py<PyUnicodeError>
impl From<&PyUnicodeError> for Py<PyUnicodeError>
source§fn from(other: &PyUnicodeError) -> Self
fn from(other: &PyUnicodeError) -> Self
source§impl From<&PyUnicodeTranslateError> for Py<PyUnicodeTranslateError>
impl From<&PyUnicodeTranslateError> for Py<PyUnicodeTranslateError>
source§fn from(other: &PyUnicodeTranslateError) -> Self
fn from(other: &PyUnicodeTranslateError) -> Self
source§impl From<&PyUnicodeWarning> for Py<PyUnicodeWarning>
impl From<&PyUnicodeWarning> for Py<PyUnicodeWarning>
source§fn from(other: &PyUnicodeWarning) -> Self
fn from(other: &PyUnicodeWarning) -> Self
source§impl From<&PyUserWarning> for Py<PyUserWarning>
impl From<&PyUserWarning> for Py<PyUserWarning>
source§fn from(other: &PyUserWarning) -> Self
fn from(other: &PyUserWarning) -> Self
source§impl From<&PyValueError> for Py<PyValueError>
impl From<&PyValueError> for Py<PyValueError>
source§fn from(other: &PyValueError) -> Self
fn from(other: &PyValueError) -> Self
source§impl From<&PyZeroDivisionError> for Py<PyZeroDivisionError>
impl From<&PyZeroDivisionError> for Py<PyZeroDivisionError>
source§fn from(other: &PyZeroDivisionError) -> Self
fn from(other: &PyZeroDivisionError) -> Self
source§impl From<&QueueEmpty> for Py<QueueEmpty>
impl From<&QueueEmpty> for Py<QueueEmpty>
source§fn from(other: &QueueEmpty) -> Self
fn from(other: &QueueEmpty) -> Self
source§impl From<&TimeoutError> for Py<TimeoutError>
impl From<&TimeoutError> for Py<TimeoutError>
source§fn from(other: &TimeoutError) -> Self
fn from(other: &TimeoutError) -> Self
source§impl<T: PyClass> From<Py<T>> for PyClassInitializer<T>
impl<T: PyClass> From<Py<T>> for PyClassInitializer<T>
source§fn from(value: Py<T>) -> PyClassInitializer<T>
fn from(value: Py<T>) -> PyClassInitializer<T>
source§impl<T> FromPyObject<'_> for Py<T>where
T: PyTypeCheck,
impl<T> FromPyObject<'_> for Py<T>where
T: PyTypeCheck,
source§fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult<Self>
fn extract_bound(ob: &Bound<'_, PyAny>) -> PyResult<Self>
Extracts Self
from the source PyObject
.
source§fn type_input() -> TypeInfo
fn type_input() -> TypeInfo
experimental-inspect
only.source§impl IntoPy<Py<CancelledError>> for &CancelledError
impl IntoPy<Py<CancelledError>> for &CancelledError
source§impl IntoPy<Py<IncompleteReadError>> for &IncompleteReadError
impl IntoPy<Py<IncompleteReadError>> for &IncompleteReadError
source§impl IntoPy<Py<InvalidStateError>> for &InvalidStateError
impl IntoPy<Py<InvalidStateError>> for &InvalidStateError
source§impl IntoPy<Py<LimitOverrunError>> for &LimitOverrunError
impl IntoPy<Py<LimitOverrunError>> for &LimitOverrunError
source§impl IntoPy<Py<PanicException>> for &PanicException
impl IntoPy<Py<PanicException>> for &PanicException
source§impl<T> IntoPy<Py<PyAny>> for &Bound<'_, T>
impl<T> IntoPy<Py<PyAny>> for &Bound<'_, T>
source§fn into_py(self, py: Python<'_>) -> PyObject
fn into_py(self, py: Python<'_>) -> PyObject
Converts &Bound
instance -> PyObject, increasing the reference count.
source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
experimental-inspect
only.source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>, T11: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>, T11: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
source§impl<K, V, H> IntoPy<Py<PyAny>> for HashMap<K, V, H>
Available on crate feature hashbrown
only.
impl<K, V, H> IntoPy<Py<PyAny>> for HashMap<K, V, H>
hashbrown
only.source§impl<K, V, H> IntoPy<Py<PyAny>> for IndexMap<K, V, H>
Available on crate feature indexmap
only.
impl<K, V, H> IntoPy<Py<PyAny>> for IndexMap<K, V, H>
indexmap
only.source§impl<T> IntoPy<Py<PyAny>> for Py<T>
impl<T> IntoPy<Py<PyAny>> for Py<T>
source§fn into_py(self, _py: Python<'_>) -> PyObject
fn into_py(self, _py: Python<'_>) -> PyObject
Converts a Py
instance to PyObject
.
Consumes self
without calling Py_DECREF()
.
source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
experimental-inspect
only.source§impl IntoPy<Py<PyArithmeticError>> for &PyArithmeticError
impl IntoPy<Py<PyArithmeticError>> for &PyArithmeticError
source§impl IntoPy<Py<PyAssertionError>> for &PyAssertionError
impl IntoPy<Py<PyAssertionError>> for &PyAssertionError
source§impl IntoPy<Py<PyAttributeError>> for &PyAttributeError
impl IntoPy<Py<PyAttributeError>> for &PyAttributeError
source§impl IntoPy<Py<PyBaseException>> for &PyBaseException
impl IntoPy<Py<PyBaseException>> for &PyBaseException
source§impl IntoPy<Py<PyBlockingIOError>> for &PyBlockingIOError
impl IntoPy<Py<PyBlockingIOError>> for &PyBlockingIOError
source§impl IntoPy<Py<PyBrokenPipeError>> for &PyBrokenPipeError
impl IntoPy<Py<PyBrokenPipeError>> for &PyBrokenPipeError
source§impl IntoPy<Py<PyBufferError>> for &PyBufferError
impl IntoPy<Py<PyBufferError>> for &PyBufferError
source§impl IntoPy<Py<PyByteArray>> for &PyByteArray
impl IntoPy<Py<PyByteArray>> for &PyByteArray
source§impl IntoPy<Py<PyBytesWarning>> for &PyBytesWarning
impl IntoPy<Py<PyBytesWarning>> for &PyBytesWarning
source§impl IntoPy<Py<PyCFunction>> for &PyCFunction
impl IntoPy<Py<PyCFunction>> for &PyCFunction
source§impl IntoPy<Py<PyChildProcessError>> for &PyChildProcessError
impl IntoPy<Py<PyChildProcessError>> for &PyChildProcessError
source§impl IntoPy<Py<PyCode>> for &PyCode
Available on non-Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.
impl IntoPy<Py<PyCode>> for &PyCode
Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.source§impl IntoPy<Py<PyConnectionError>> for &PyConnectionError
impl IntoPy<Py<PyConnectionError>> for &PyConnectionError
source§impl IntoPy<Py<PyConnectionResetError>> for &PyConnectionResetError
impl IntoPy<Py<PyConnectionResetError>> for &PyConnectionResetError
source§impl IntoPy<Py<PyDateTime>> for &PyDateTime
Available on non-Py_LIMITED_API
only.
impl IntoPy<Py<PyDateTime>> for &PyDateTime
Py_LIMITED_API
only.source§impl IntoPy<Py<PyDeprecationWarning>> for &PyDeprecationWarning
impl IntoPy<Py<PyDeprecationWarning>> for &PyDeprecationWarning
source§impl IntoPy<Py<PyDictItems>> for &PyDictItems
impl IntoPy<Py<PyDictItems>> for &PyDictItems
source§impl IntoPy<Py<PyDictKeys>> for &PyDictKeys
impl IntoPy<Py<PyDictKeys>> for &PyDictKeys
source§impl IntoPy<Py<PyDictValues>> for &PyDictValues
impl IntoPy<Py<PyDictValues>> for &PyDictValues
source§impl IntoPy<Py<PyEOFError>> for &PyEOFError
impl IntoPy<Py<PyEOFError>> for &PyEOFError
source§impl IntoPy<Py<PyEllipsis>> for &PyEllipsis
impl IntoPy<Py<PyEllipsis>> for &PyEllipsis
source§impl IntoPy<Py<PyEncodingWarning>> for &PyEncodingWarning
impl IntoPy<Py<PyEncodingWarning>> for &PyEncodingWarning
source§impl IntoPy<Py<PyEnvironmentError>> for &PyEnvironmentError
impl IntoPy<Py<PyEnvironmentError>> for &PyEnvironmentError
source§impl IntoPy<Py<PyException>> for &PyException
impl IntoPy<Py<PyException>> for &PyException
source§impl IntoPy<Py<PyFileExistsError>> for &PyFileExistsError
impl IntoPy<Py<PyFileExistsError>> for &PyFileExistsError
source§impl IntoPy<Py<PyFileNotFoundError>> for &PyFileNotFoundError
impl IntoPy<Py<PyFileNotFoundError>> for &PyFileNotFoundError
source§impl IntoPy<Py<PyFloatingPointError>> for &PyFloatingPointError
impl IntoPy<Py<PyFloatingPointError>> for &PyFloatingPointError
source§impl IntoPy<Py<PyFrame>> for &PyFrame
Available on non-Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.
impl IntoPy<Py<PyFrame>> for &PyFrame
Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.source§impl IntoPy<Py<PyFrozenSet>> for &PyFrozenSet
impl IntoPy<Py<PyFrozenSet>> for &PyFrozenSet
source§impl IntoPy<Py<PyFunction>> for &PyFunction
impl IntoPy<Py<PyFunction>> for &PyFunction
source§impl IntoPy<Py<PyFutureWarning>> for &PyFutureWarning
impl IntoPy<Py<PyFutureWarning>> for &PyFutureWarning
source§impl IntoPy<Py<PyGeneratorExit>> for &PyGeneratorExit
impl IntoPy<Py<PyGeneratorExit>> for &PyGeneratorExit
source§impl IntoPy<Py<PyImportError>> for &PyImportError
impl IntoPy<Py<PyImportError>> for &PyImportError
source§impl IntoPy<Py<PyImportWarning>> for &PyImportWarning
impl IntoPy<Py<PyImportWarning>> for &PyImportWarning
source§impl IntoPy<Py<PyIndexError>> for &PyIndexError
impl IntoPy<Py<PyIndexError>> for &PyIndexError
source§impl IntoPy<Py<PyInterruptedError>> for &PyInterruptedError
impl IntoPy<Py<PyInterruptedError>> for &PyInterruptedError
source§impl IntoPy<Py<PyIsADirectoryError>> for &PyIsADirectoryError
impl IntoPy<Py<PyIsADirectoryError>> for &PyIsADirectoryError
source§impl IntoPy<Py<PyIterator>> for &PyIterator
impl IntoPy<Py<PyIterator>> for &PyIterator
source§impl IntoPy<Py<PyKeyError>> for &PyKeyError
impl IntoPy<Py<PyKeyError>> for &PyKeyError
source§impl IntoPy<Py<PyKeyboardInterrupt>> for &PyKeyboardInterrupt
impl IntoPy<Py<PyKeyboardInterrupt>> for &PyKeyboardInterrupt
source§impl IntoPy<Py<PyLookupError>> for &PyLookupError
impl IntoPy<Py<PyLookupError>> for &PyLookupError
source§impl IntoPy<Py<PyMemoryError>> for &PyMemoryError
impl IntoPy<Py<PyMemoryError>> for &PyMemoryError
source§impl IntoPy<Py<PyMemoryView>> for &PyMemoryView
impl IntoPy<Py<PyMemoryView>> for &PyMemoryView
source§impl IntoPy<Py<PyModuleNotFoundError>> for &PyModuleNotFoundError
impl IntoPy<Py<PyModuleNotFoundError>> for &PyModuleNotFoundError
source§impl IntoPy<Py<PyNameError>> for &PyNameError
impl IntoPy<Py<PyNameError>> for &PyNameError
source§impl IntoPy<Py<PyNotADirectoryError>> for &PyNotADirectoryError
impl IntoPy<Py<PyNotADirectoryError>> for &PyNotADirectoryError
source§impl IntoPy<Py<PyNotImplemented>> for &PyNotImplemented
impl IntoPy<Py<PyNotImplemented>> for &PyNotImplemented
source§impl IntoPy<Py<PyNotImplementedError>> for &PyNotImplementedError
impl IntoPy<Py<PyNotImplementedError>> for &PyNotImplementedError
source§impl IntoPy<Py<PyOverflowError>> for &PyOverflowError
impl IntoPy<Py<PyOverflowError>> for &PyOverflowError
source§impl IntoPy<Py<PyPermissionError>> for &PyPermissionError
impl IntoPy<Py<PyPermissionError>> for &PyPermissionError
source§impl IntoPy<Py<PyProcessLookupError>> for &PyProcessLookupError
impl IntoPy<Py<PyProcessLookupError>> for &PyProcessLookupError
source§impl IntoPy<Py<PyRecursionError>> for &PyRecursionError
impl IntoPy<Py<PyRecursionError>> for &PyRecursionError
source§impl IntoPy<Py<PyReferenceError>> for &PyReferenceError
impl IntoPy<Py<PyReferenceError>> for &PyReferenceError
source§impl IntoPy<Py<PyResourceWarning>> for &PyResourceWarning
impl IntoPy<Py<PyResourceWarning>> for &PyResourceWarning
source§impl IntoPy<Py<PyRuntimeError>> for &PyRuntimeError
impl IntoPy<Py<PyRuntimeError>> for &PyRuntimeError
source§impl IntoPy<Py<PyRuntimeWarning>> for &PyRuntimeWarning
impl IntoPy<Py<PyRuntimeWarning>> for &PyRuntimeWarning
source§impl IntoPy<Py<PySequence>> for &PySequence
impl IntoPy<Py<PySequence>> for &PySequence
source§impl IntoPy<Py<PyStopAsyncIteration>> for &PyStopAsyncIteration
impl IntoPy<Py<PyStopAsyncIteration>> for &PyStopAsyncIteration
source§impl IntoPy<Py<PyStopIteration>> for &PyStopIteration
impl IntoPy<Py<PyStopIteration>> for &PyStopIteration
source§impl IntoPy<Py<PySyntaxError>> for &PySyntaxError
impl IntoPy<Py<PySyntaxError>> for &PySyntaxError
source§impl IntoPy<Py<PySyntaxWarning>> for &PySyntaxWarning
impl IntoPy<Py<PySyntaxWarning>> for &PySyntaxWarning
source§impl IntoPy<Py<PySystemError>> for &PySystemError
impl IntoPy<Py<PySystemError>> for &PySystemError
source§impl IntoPy<Py<PySystemExit>> for &PySystemExit
impl IntoPy<Py<PySystemExit>> for &PySystemExit
source§impl IntoPy<Py<PyTimeoutError>> for &PyTimeoutError
impl IntoPy<Py<PyTimeoutError>> for &PyTimeoutError
source§impl IntoPy<Py<PyTraceback>> for &PyTraceback
impl IntoPy<Py<PyTraceback>> for &PyTraceback
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
source§impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>, T11: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
impl<T0: IntoPy<PyObject>, T1: IntoPy<PyObject>, T2: IntoPy<PyObject>, T3: IntoPy<PyObject>, T4: IntoPy<PyObject>, T5: IntoPy<PyObject>, T6: IntoPy<PyObject>, T7: IntoPy<PyObject>, T8: IntoPy<PyObject>, T9: IntoPy<PyObject>, T10: IntoPy<PyObject>, T11: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
source§impl IntoPy<Py<PyTypeError>> for &PyTypeError
impl IntoPy<Py<PyTypeError>> for &PyTypeError
source§impl IntoPy<Py<PyUnboundLocalError>> for &PyUnboundLocalError
impl IntoPy<Py<PyUnboundLocalError>> for &PyUnboundLocalError
source§impl IntoPy<Py<PyUnicodeDecodeError>> for &PyUnicodeDecodeError
impl IntoPy<Py<PyUnicodeDecodeError>> for &PyUnicodeDecodeError
source§impl IntoPy<Py<PyUnicodeEncodeError>> for &PyUnicodeEncodeError
impl IntoPy<Py<PyUnicodeEncodeError>> for &PyUnicodeEncodeError
source§impl IntoPy<Py<PyUnicodeError>> for &PyUnicodeError
impl IntoPy<Py<PyUnicodeError>> for &PyUnicodeError
source§impl IntoPy<Py<PyUnicodeWarning>> for &PyUnicodeWarning
impl IntoPy<Py<PyUnicodeWarning>> for &PyUnicodeWarning
source§impl IntoPy<Py<PyUserWarning>> for &PyUserWarning
impl IntoPy<Py<PyUserWarning>> for &PyUserWarning
source§impl IntoPy<Py<PyValueError>> for &PyValueError
impl IntoPy<Py<PyValueError>> for &PyValueError
source§impl IntoPy<Py<PyZeroDivisionError>> for &PyZeroDivisionError
impl IntoPy<Py<PyZeroDivisionError>> for &PyZeroDivisionError
source§impl IntoPy<Py<QueueEmpty>> for &QueueEmpty
impl IntoPy<Py<QueueEmpty>> for &QueueEmpty
source§impl IntoPy<Py<TimeoutError>> for &TimeoutError
impl IntoPy<Py<TimeoutError>> for &TimeoutError
source§impl<T> Serialize for Py<T>
Available on crate feature serde
only.
impl<T> Serialize for Py<T>
serde
only.source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
source§impl<T> ToPyObject for Py<T>
impl<T> ToPyObject for Py<T>
impl<T> Send for Py<T>
impl<T> Sync for Py<T>
Auto Trait Implementations§
impl<T> Freeze for Py<T>
impl<T> RefUnwindSafe for Py<T>where
T: RefUnwindSafe,
impl<T> Unpin for Py<T>where
T: Unpin,
impl<T> UnwindSafe for Py<T>where
T: UnwindSafe,
Blanket Implementations§
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<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
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 more