kups.core.utils.msgpack
¶
deserialize(data)
¶
Deserialize msgpack bytes back to a pytree with numpy arrays.
Inverse of :func:serialize. Encoded array dicts are restored to numpy
arrays; all other values are returned as plain Python objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Bytes produced by :func: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The reconstructed pytree with numpy array leaves. |
Source code in src/kups/core/utils/msgpack.py
serialize(obj)
¶
Serialize a pytree with jax/numpy arrays to msgpack bytes.
Array leaves are encoded as {"shape": ..., "dtype": ..., "data": ...}
dicts. Non-array leaves (ints, floats, strings, etc.) are passed through
to msgpack as-is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
A pytree whose leaves are jax/numpy arrays or plain Python values. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The msgpack-encoded bytes. |