[][src]Module rustypy::pytypes::pytuple

An analog of a Python tuple, will accept an undefined number of any other supported types.

You can construct it using the pytuple! macro, ie:

use rustypy::PyArg;
pytuple!(PyArg::I64(10), PyArg::F32(10.5));

You must pass the variety of the argument using the PyArg enum.

When extracting elements in Python with the FFI, elements are copied, not moved unless possible (ie. content of inner containers may or may not be moved out), and when free'd all the original elements are dropped.

PyTuples behave exactly as Python tuples: they are immutable, but provide interior mutability. For example, you can pop elements from an inner PyList, although the PyList cannot be moved out of a PyTuple (without completely destructuring it).

Safety

PyTuple must be passed between Rust and Python as a raw pointer. You can get a raw pointer using into_raw and convert from a raw pointer using the "static" method PyDict::from_ptr which is unsafe as it requires dereferencing a raw pointer.

Unpacking PyTuple from Python

Is recommended to use the unpack_pytuple! macro in order to convert a PyTuple to a Rust native type. Check the macro documentation for more info.

Structs

PyTuple

An analog of a Python tuple, will accept an undefined number of other supported types.