heros.serdes¶
Attributes¶
Classes¶
An object store to be used to keep week references to objects identified by a serializable identifier (int64). |
|
Functions¶
|
Handle custom types in serialization. |
|
Decode the custom CBOR tags used by HEROS. |
|
|
|
Deserialize a CBOR byte string. |
Module Contents¶
- heros.serdes.ndarray_tag = 4242¶
- heros.serdes.hero_tag = 9000¶
- heros.serdes.unserializable_tag = 9001¶
- heros.serdes.unserializable_object_reference_tag = 9002¶
- heros.serdes.hero_event_tag = 9003¶
- heros.serdes.hero_method_tag = 9004¶
- heros.serdes.hero_exception_tag = 9005¶
- class heros.serdes.ObjectStore[source]¶
An object store to be used to keep week references to objects identified by a serializable identifier (int64).
- _cache¶
- add(object: ObjectStore.add.object) int[source]¶
Add object to store and return it’s identifier
- Parameters:
object – object to store
- Returns:
Identifier to retrieve the object from the store again
- get(identifier: int) object[source]¶
Retrieve an object identified by :param:identifier from the store. If the object does not exist any more, None is returned.
- Parameters:
identifier – the identifier obtained when storing the object
- Returns:
object corresponding to the identifier or None if the object does not exist any more
- heros.serdes.obj_store¶
- class heros.serdes.UnserializableRemoteObject(type: str, id: int, representation: str)[source]¶
- type¶
- representation¶
- id¶
- heros.serdes.cbor_tag_hook(decoder, tag, shareable_index=None, *, make_remote: collections.abc.Callable[..., Any] | None = None)[source]¶
Decode the custom CBOR tags used by HEROS.
- Parameters:
decoder – the CBOR decoder
tag – the tagged value to decode
shareable_index – index of a shareable value, passed in by cbor2
make_remote – factory called as
make_remote(name, realm=realm)to build a HERO from a HERO tag. Defaults toheros.RemoteHERO.
- Returns:
The decoded object, or the unchanged tag if it is not a HEROS tag.
- heros.serdes.deserialize(bytes, *, make_remote: collections.abc.Callable[..., Any] | None = None)[source]¶
Deserialize a CBOR byte string.
- Parameters:
bytes – the byte string to deserialize
make_remote – factory used to build HEROs, see
cbor_tag_hook(). Defaults toheros.RemoteHERO.
- Returns:
The deserialized object.