distributed 2021.10.0

Returns
serialize(x, serializers=None, on_error='message', context=None, iterate_collection=None)

This takes in an arbitrary Python object and returns a msgpack serializable header and a list of bytes or memoryview objects.

The serialization protocols to use are configurable: a list of names define the set of serializers to use, in order. These names are keys in the serializer_registry dict (e.g., 'pickle', 'msgpack'), which maps to the de/serialize functions. The name 'dask' is special, and will use the per-class serialization methods. None gives the default list ['dask', 'pickle'] .

Notes on the iterate_collection argument (only relevant when x is a collection): - iterate_collection=True : Serialize collection elements separately. - iterate_collection=False : Serialize collection elements together. - iterate_collection=None (default): Infer the best setting.

Returns

header: dictionary containing any msgpack-serializable metadata
frames: list of bytes or memoryviews, commonly of length one

Convert object to a header and list of bytestrings

See Also

deserialize

Convert header and frames back to object

register_serialization

Register custom serialization functions

to_serialize

Mark that data in a message should be serialized

Examples

This example is valid syntax, but we were not able to check execution
>>> serialize(1)
({}, [b'\x80\x04\x95\x03\x00\x00\x00\x00\x00\x00\x00K\x01.'])
This example is valid syntax, but we were not able to check execution
>>> serialize(b'123')  # some special types get custom treatment
({'type': 'builtins.bytes'}, [b'123'])
This example is valid syntax, but we were not able to check execution
>>> deserialize(*serialize(1))
1
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /distributed/protocol/serialize.py#201
type: <class 'function'>
Commit: