Skip to main content

Module codegen_py

Module codegen_py 

Source
Expand description

PyO3 bindings and the Python wrapper package for a bridge crate.

Like the JS side, the binding layer follows port.rs: strings, ints, floats, bools and lists or options of those cross natively; anything structured crosses as JSON text, which the wrapper package (python/<lib>/__init__.py) encodes and decodes with Python markers.

Constants§

PYCONV_RS
src/pyconv.rs: Python objects to serde_json::Value and back, in Rust, without JSON text. Values the JSON model lacks use the same markers as recorded cases: $tuple, $set, $bytes, $int (beyond i64), $dict (non-string keys), $num (NaN, infinities, -0).
PYNUM_RS
src/pynum.rs: Python’s int-or-float, for ports of code that takes either.

Functions§

has_literal_default
Whether a parameter keeps Python’s literal default (and is a plain, non-Option type).
lib_rs
package_init
The wrapper package: imports _native, converting structured values.
rust_literal
A Python literal default as a Rust expression, for #[pyo3(signature = ...)]: strings, numbers and booleans. None and other expressions return None (the parameter is an Option, and None stands for the default).