用法:
distributed.protocol.serialize.serialize(x, serializers=None, on_error='message', context=None, iterate_collection=None)
將對象轉換為標頭和字節串列表
這接受一個任意 Python 對象並返回一個 msgpack 可序列化標頭和一個字節列表或 memoryview 對象。
要使用的序列化協議是可配置的:名稱列表按順序定義要使用的序列化程序集。這些名稱是
serializer_registry
dict 中的鍵(例如,‘pickle’, ‘msgpack’),它映射到 de/serialize 函數。名稱‘dask’ 很特殊,將使用per-class 序列化方法。None
給出默認列表['dask', 'pickle']
。iterate_collection
參數的注意事項(僅當x
是一個集合時才相關): -iterate_collection=True
:單獨序列化集合元素。 -iterate_collection=False
:一起序列化集合元素。 -iterate_collection=None
(默認):推斷最佳設置。- 標頭:包含任何 msgpack-serializable 元數據的字典
- 幀:字節或內存視圖列表,通常長度為 1
返回:
例子:
>>> serialize(1) ({}, [b'\x80\x04\x95\x03\x00\x00\x00\x00\x00\x00\x00K\x01.'])
>>> serialize(b'123') # some special types get custom treatment ({'type': 'builtins.bytes'}, [b'123'])
>>> deserialize(*serialize(1)) 1
相關用法
- Python distributed.protocol.serialize.register_generic用法及代碼示例
- Python distributed.performance_report用法及代碼示例
- Python distributed.Client.gather用法及代碼示例
- Python distributed.recreate_tasks.ReplayTaskClient.recreate_task_locally用法及代碼示例
- Python distributed.diagnostics.plugin.SchedulerPlugin用法及代碼示例
- Python distributed.Client.ncores用法及代碼示例
- Python distributed.Client.retire_workers用法及代碼示例
- Python distributed.Client.unregister_worker_plugin用法及代碼示例
- Python distributed.fire_and_forget用法及代碼示例
- Python distributed.Client.set_metadata用法及代碼示例
- Python distributed.Client.scheduler_info用法及代碼示例
- Python distributed.Client.submit用法及代碼示例
- Python distributed.Client.compute用法及代碼示例
- Python distributed.SpecCluster.scale用法及代碼示例
- Python distributed.get_worker用法及代碼示例
- Python distributed.SpecCluster.scale_up用法及代碼示例
- Python distributed.Client.nthreads用法及代碼示例
- Python distributed.comm.resolve_address用法及代碼示例
- Python distributed.Client.unpublish_dataset用法及代碼示例
- Python distributed.get_task_stream用法及代碼示例
注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 distributed.protocol.serialize.serialize。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。