| Crates.io | pyany-serde |
| lib.rs | pyany-serde |
| version | 0.5.0 |
| created_at | 2025-02-01 05:07:36.469451+00 |
| updated_at | 2025-04-26 21:02:05.109842+00 |
| description | Serialization and deserialization for Python objects |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1538166 |
| size | 190,205 |
A Rust crate which defines a trait for serializing and deserializing Python objects. Because this trait does not have the 'py lifetime specifier, trait objects can be stored in Python classes, which is often useful for rust backends for Python projects. This allows for the different PyAnySerde implementations to be created and bound in the Python interpreter. There are a variety of implementations provided for standard Python objects, and there is a PythonSerde abstract Python class which can be implemented and turned into a Box
The use case for this crate is demonstrated in rlgym-learn - the user writes Python code which instantiates an enum defining the type of PyAnySerde to be used to communicate across shared memory, and then this enum is used to construct the Boxappend and retrieve methods. Some structs (like NumpyDynamicShapeSerde) implementing the PyAnySerde trait rely on alignment for deserialization, and so these append and retrieve methods must write directly to the buffer so that the alignment is known.