用法:
distributed.protocol.serialize.register_generic(cls, serializer_name='dask', serialize_func=<dask.utils.Dispatch object>, deserialize_func=<dask.utils.Dispatch object>)注冊(反)序列化以遍曆 __dict__
通常在為 Dask 的自定義序列化注冊新類時,您需要管理標題和幀,這可能很乏味。如果您隻想遍曆對象並將序列化應用於對象的所有屬性,那麽此函數可能會提供更簡單的路徑。
這為自定義 Dask 序列化係列注冊了一個類。它通過遍曆其屬性的__dict__並遞歸地應用
serialize和deserialize來對其進行序列化。它收集一組幀並在標題中保留小屬性。反序列化逆轉了這個過程。如果滿足以下條件,這是一個好主意:
對象的大部分字節由 Dask 的自定義序列化已經很好處理的數據類型組成,例如 Numpy 數組。
您的對象不需要任何特殊的構造函數邏輯,除了 object.__new__(cls)
例子:
>>> import sklearn.base >>> from distributed.protocol import register_generic >>> register_generic(sklearn.base.BaseEstimator)
相關用法
- Python distributed.protocol.serialize.serialize用法及代碼示例
- 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.register_generic。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
