Skip to main content

Module prelude

Module prelude 

Source
Expand description

Prelude module for convenient imports

Re-exports§

pub use crate::Error;
pub use crate::Result;
pub use crate::init;
pub use crate::init_with_ml;
pub use crate::exec;
pub use crate::eval;
pub use crate::IntoPython;
pub use crate::FromPython;

Macros§

py_eval
Macro to evaluate Python expression with type inference Usage: let result: i32 = py_eval!(“1 + 1”);
py_exec
Macro to execute Python code without returning a value Usage: py_exec!(“import numpy as np\nprint(np.version)”)
py_locals
Helper macro to create a locals HashMap Usage: py_locals!{“x” => 5, “y” => 10}
python
Simple macro to run Python code Usage: python!(“print(‘Hello from Python’)”)
wrap_pyfunction
Wraps a Rust function annotated with #[pyfunction].
wrap_pyfunction_boundDeprecated
Wraps a Rust function annotated with #[pyfunction].

Structs§

Borrowed
A borrowed equivalent to Bound.
Bound
A GIL-attached equivalent to Py<T>.
Py
A GIL-independent reference to an object allocated on the Python heap.
PyAny
Represents any Python object.
PyClassInitializer
Initializer for our #[pyclass] system.
PyErr
Represents a Python exception.
PyModule
Represents a Python module object.
PyRef
A wrapper type for an immutably borrowed value from a Bound<'py, T>.
PyRefMut
A wrapper type for a mutably borrowed value from a Bound<'py, T>.
Python
A marker token that represents holding the GIL.

Traits§

FromPyObject
Extract a type from a Python object.
IntoPyDeprecated
Defines a conversion from a Rust type to a Python object.
IntoPyObject
Defines a conversion from a Rust type to a Python object, which may fail.
PyAnyMethods
This trait represents the Python APIs which are usable on all Python objects.
PyBoolMethods
Implementation of functionality for PyBool.
PyByteArrayMethods
Implementation of functionality for PyByteArray.
PyBytesMethods
Implementation of functionality for PyBytes.
PyCapsuleMethods
Implementation of functionality for PyCapsule.
PyComplexMethods
Implementation of functionality for PyComplex.
PyDictMethods
Implementation of functionality for PyDict.
PyFloatMethods
Implementation of functionality for PyFloat.
PyFrozenSetMethods
Implementation of functionality for PyFrozenSet.
PyListMethods
Implementation of functionality for PyList.
PyMappingMethods
Implementation of functionality for PyMapping.
PyMappingProxyMethods
Implementation of functionality for PyMappingProxy.
PyModuleMethods
Implementation of functionality for PyModule.
PySequenceMethods
Implementation of functionality for PySequence.
PySetMethods
Implementation of functionality for PySet.
PySliceMethods
Implementation of functionality for PySlice.
PyStringMethods
Implementation of functionality for PyString.
PyTracebackMethods
Implementation of functionality for PyTraceback.
PyTupleMethods
Implementation of functionality for PyTuple.
PyTypeMethods
Implementation of functionality for PyType.
PyWeakrefMethods
Implementation of functionality for PyWeakref.
ToPyObjectDeprecated
Conversion trait that allows various objects to be converted into PyObject.

Type Aliases§

PyObject
A commonly-used alias for Py<PyAny>.
PyResult
Represents the result of a Python call.

Attribute Macros§

pyclass
pyfunction
A proc macro used to expose Rust functions to Python.
pymethods
A proc macro used to expose methods to Python.
pymodule
A proc macro used to implement Python modules.

Derive Macros§

FromPyObject
IntoPyObject
IntoPyObjectRef