heros.serdes

Attributes

Classes

ObjectStore

An object store to be used to keep week references to objects identified by a serializable identifier (int64).

UnserializableRemoteObject

Functions

is_builtin_class_instance(obj)

cbor_default_encoder(encoder, value)

Handle custom types in serialization.

cbor_tag_hook(decoder, tag[, shareable_index, make_remote])

Decode the custom CBOR tags used by HEROS.

serialize(obj)

deserialize(bytes, *[, make_remote])

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
heros.serdes.is_builtin_class_instance(obj)[source]
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
__str__()[source]
__repr__()[source]
heros.serdes.cbor_default_encoder(encoder, value)[source]

Handle custom types in serialization.

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 to heros.RemoteHERO.

Returns:

The decoded object, or the unchanged tag if it is not a HEROS tag.

heros.serdes.serialize(obj)[source]
heros.serdes.deserialize(bytes, *, make_remote: collections.abc.Callable[..., Any] | None = None)[source]

Deserialize a CBOR byte string.

Parameters:
Returns:

The deserialized object.