cengal.parallel_execution.coroutines.coro_standard_services.remote_nodes.versions.v_0.serializers
Module Docstring Docstrings: http://www.python.org/dev/peps/pep-0257/
1#!/usr/bin/env python 2# coding=utf-8 3 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space> 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18 19""" 20Module Docstring 21Docstrings: http://www.python.org/dev/peps/pep-0257/ 22""" 23 24 25__author__ = "ButenkoMS <gtalk@butenkoms.space>" 26__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>" 27__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ] 28__license__ = "Apache License, Version 2.0" 29__version__ = "4.4.1" 30__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>" 31__email__ = "gtalk@butenkoms.space" 32# __status__ = "Prototype" 33__status__ = "Development" 34# __status__ = "Production" 35 36 37from cengal.data_manipulation.serialization import Serializer, Serializers, SerializerFeatures, DataFormats, Tags, best_serializer_for_standard_data 38from enum import Enum 39from typing import Dict, Any 40 41from .commands import * 42 43 44class SerializerID(Enum): 45 multi_platform__initial_communication = -1 46 multi_platform_fast = 0 47 multi_platform = 1 48 current_platform = 2 49 current_platform__custom_types = 3 50 51 52desired_features: Dict[SerializerID, SerializerFeatures] = { 53 SerializerID.multi_platform__initial_communication.value: { 54 DataFormats.json, 55 Tags.deep, 56 Tags.multi_platform, 57 }, 58 SerializerID.multi_platform_fast.value: { 59 DataFormats.any, 60 Tags.deep, 61 Tags.multi_platform, 62 Tags.can_use_bytes, 63 }, 64 SerializerID.multi_platform.value: { 65 DataFormats.any, 66 Tags.deep, 67 Tags.multi_platform, 68 Tags.can_use_bytes, 69 Tags.decode_str_as_str, 70 Tags.decode_list_as_list, 71 }, 72 SerializerID.current_platform.value: { 73 DataFormats.any, 74 Tags.deep, 75 Tags.can_use_set, 76 Tags.can_use_bytes, 77 Tags.decode_str_as_str, 78 Tags.decode_bytes_as_bytes, 79 Tags.decode_tuple_as_tuple, 80 Tags.decode_list_as_list, 81 }, 82 SerializerID.current_platform__custom_types.value: { 83 DataFormats.any, 84 Tags.current_platform, 85 Tags.deep, 86 Tags.can_use_custom_types, 87 Tags.can_use_bytes, 88 Tags.can_use_set, 89 Tags.decode_str_as_str, 90 Tags.decode_bytes_as_bytes, 91 Tags.decode_tuple_as_tuple, 92 Tags.decode_list_as_list, 93 }, 94} 95 96 97test_data: Dict[SerializerID, Any] = { 98 SerializerID.multi_platform__initial_communication.value: { 99 Fields.command_name.value: Commands.declare_client_node.value, 100 Fields.request_id.value: 10, 101 Fields.in_response_to.value: 10, 102 Fields.is_response_required.value: True, 103 Fields.data.value: { 104 CommandDataFieldsDeclareClientNode.platform_name.value: 'Python 3.11.0', 105 CommandDataFieldsDeclareClientNode.suggested_serializers.value: { 106 SerializerID.multi_platform_fast.value: [ 107 Serializers.msgpack_fast, 108 Serializers.orjson, 109 Serializers.cbor2, 110 Serializers.ujson, 111 Serializers.simplejson, 112 Serializers.json, 113 ], 114 SerializerID.multi_platform.value: [ 115 Serializers.msgpack, 116 Serializers.orjson, 117 Serializers.cbor2, 118 Serializers.ujson, 119 Serializers.simplejson, 120 Serializers.json, 121 ], 122 SerializerID.current_platform.value: [ 123 Serializers.marshal_compat_4, 124 Serializers.msgpack, 125 Serializers.orjson, 126 Serializers.cbor2, 127 Serializers.ujson, 128 Serializers.simplejson, 129 Serializers.json, 130 Serializers.cloudpickle_compat_5, 131 Serializers.cpickle_compat_5, 132 Serializers.pickle_compat_5, 133 ], 134 SerializerID.current_platform__custom_types.value: [ 135 Serializers.cloudpickle_compat_5, 136 Serializers.cpickle_compat_5, 137 Serializers.pickle_compat_5, 138 ], 139 } 140 } 141 }, 142 SerializerID.multi_platform_fast.value: { 143 DataFormats.any, 144 Tags.deep, 145 Tags.multi_platform, 146 Tags.can_use_bytes, 147 }, 148 SerializerID.multi_platform.value: { 149 DataFormats.any, 150 Tags.deep, 151 Tags.multi_platform, 152 Tags.can_use_bytes, 153 Tags.decode_str_as_str, 154 Tags.decode_list_as_list, 155 }, 156 SerializerID.current_platform.value: { 157 DataFormats.any, 158 Tags.deep, 159 Tags.can_use_set, 160 Tags.can_use_bytes, 161 Tags.decode_str_as_str, 162 Tags.decode_bytes_as_bytes, 163 Tags.decode_tuple_as_tuple, 164 Tags.decode_list_as_list, 165 }, 166 SerializerID.current_platform__custom_types.value: { 167 DataFormats.any, 168 Tags.current_platform, 169 Tags.deep, 170 Tags.can_use_custom_types, 171 Tags.can_use_bytes, 172 Tags.can_use_set, 173 Tags.decode_str_as_str, 174 Tags.decode_bytes_as_bytes, 175 Tags.decode_tuple_as_tuple, 176 Tags.decode_list_as_list, 177 }, 178} 179 180 181def benchmark(test_data: Dict[SerializerID, Any]) -> Dict[SerializerID, Serializer]: 182 ...
class
SerializerID(enum.Enum):
45class SerializerID(Enum): 46 multi_platform__initial_communication = -1 47 multi_platform_fast = 0 48 multi_platform = 1 49 current_platform = 2 50 current_platform__custom_types = 3
An enumeration.
multi_platform__initial_communication =
<SerializerID.multi_platform__initial_communication: -1>
multi_platform_fast =
<SerializerID.multi_platform_fast: 0>
multi_platform =
<SerializerID.multi_platform: 1>
current_platform =
<SerializerID.current_platform: 2>
current_platform__custom_types =
<SerializerID.current_platform__custom_types: 3>
Inherited Members
- enum.Enum
- name
- value
desired_features: Dict[SerializerID, Set[Union[cengal.data_manipulation.serialization.versions.v_0.serialization.Tags, cengal.data_manipulation.serialization.versions.v_0.serialization.DataFormats]]] =
{-1: {<DataFormats.json: 1>, <Tags.multi_platform: 3>, <Tags.deep: 1>}, 0: {<DataFormats.any: 0>, <Tags.multi_platform: 3>, <Tags.can_use_bytes: 8>, <Tags.deep: 1>}, 1: {<Tags.multi_platform: 3>, <Tags.deep: 1>, <DataFormats.any: 0>, <Tags.can_use_bytes: 8>, <Tags.decode_list_as_list: 16>, <Tags.decode_str_as_str: 11>}, 2: {<Tags.decode_bytes_as_bytes: 12>, <Tags.deep: 1>, <DataFormats.any: 0>, <Tags.can_use_bytes: 8>, <Tags.decode_tuple_as_tuple: 15>, <Tags.can_use_set: 7>, <Tags.decode_list_as_list: 16>, <Tags.decode_str_as_str: 11>}, 3: {<Tags.decode_bytes_as_bytes: 12>, <Tags.deep: 1>, <Tags.current_platform: 4>, <DataFormats.any: 0>, <Tags.decode_tuple_as_tuple: 15>, <Tags.decode_str_as_str: 11>, <Tags.can_use_set: 7>, <Tags.decode_list_as_list: 16>, <Tags.can_use_bytes: 8>, <Tags.can_use_custom_types: 9>}}
test_data: Dict[SerializerID, Any] =
{-1: {0: 0, 1: 10, 2: 10, 3: True, 5: {0: 'Python 3.11.0', 1: {0: [<Serializers.msgpack_fast: 6>, <Serializers.orjson: 3>, <Serializers.cbor2: 9>, <Serializers.ujson: 2>, <Serializers.simplejson: 1>, <Serializers.json: 0>], 1: [<Serializers.msgpack: 7>, <Serializers.orjson: 3>, <Serializers.cbor2: 9>, <Serializers.ujson: 2>, <Serializers.simplejson: 1>, <Serializers.json: 0>], 2: [<Serializers.marshal_compat_4: 11>, <Serializers.msgpack: 7>, <Serializers.orjson: 3>, <Serializers.cbor2: 9>, <Serializers.ujson: 2>, <Serializers.simplejson: 1>, <Serializers.json: 0>, <Serializers.cloudpickle_compat_5: 31>, <Serializers.cpickle_compat_5: 25>, <Serializers.pickle_compat_5: 18>], 3: [<Serializers.cloudpickle_compat_5: 31>, <Serializers.cpickle_compat_5: 25>, <Serializers.pickle_compat_5: 18>]}}}, 0: {<DataFormats.any: 0>, <Tags.multi_platform: 3>, <Tags.can_use_bytes: 8>, <Tags.deep: 1>}, 1: {<Tags.multi_platform: 3>, <Tags.deep: 1>, <DataFormats.any: 0>, <Tags.can_use_bytes: 8>, <Tags.decode_list_as_list: 16>, <Tags.decode_str_as_str: 11>}, 2: {<Tags.decode_bytes_as_bytes: 12>, <Tags.deep: 1>, <DataFormats.any: 0>, <Tags.can_use_bytes: 8>, <Tags.decode_tuple_as_tuple: 15>, <Tags.can_use_set: 7>, <Tags.decode_list_as_list: 16>, <Tags.decode_str_as_str: 11>}, 3: {<Tags.decode_bytes_as_bytes: 12>, <Tags.deep: 1>, <Tags.current_platform: 4>, <DataFormats.any: 0>, <Tags.decode_tuple_as_tuple: 15>, <Tags.decode_str_as_str: 11>, <Tags.can_use_set: 7>, <Tags.decode_list_as_list: 16>, <Tags.can_use_bytes: 8>, <Tags.can_use_custom_types: 9>}}
def
benchmark( test_data: Dict[SerializerID, Any]) -> Dict[SerializerID, cengal.data_manipulation.serialization.versions.v_0.serialization.Serializer]: