{"id":426694,"date":"2024-07-19T21:00:55","date_gmt":"2024-07-19T21:00:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=426694"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=426694","title":{"rendered":"<span>msgspec. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0433\u043e \u0443\u0433\u043e\u0434\u043d\u043e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a JSON, TOML, YAML \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438.<\/p>\n<p><code>msgspec<\/code>\u00a0\u2014 \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u044d\u0442\u0438\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c\u00a0\u0431\u044b\u0442\u044c\u00a0\u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0414\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u043e\u0434\u0438\u043d \u0438\u043c\u043f\u043e\u0440\u0442, \u0447\u0442\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0432\u0430\u043c.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u0434\u0435\u0440\u044b\/\u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432: JSON, MessagePack, YAML \u0438 TOMI. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 <\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 (\u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 attrs\/pydantic, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435)<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<pre><code class=\"bash\"> pip3 install \"msgspec[toml,yaml]\"<\/code><\/pre>\n<p>\u0411\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 json \u0438 messagepack.<\/p>\n<h2>\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \/ \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u0435\u043d \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">import msgspec  a = {\"1\": 2, \"3\": 4} encoded_json_data = msgspec.json.encode(a) print(encoded_json_data)  # b'{\"1\": 2, \"3\": 4}'  decoded_data = msgspec.json.decode(encoded_json_data) print(decoded_data)  # {'1': 2, '3': 4}  yaml_data = msgspec.yaml.encode(a) print(yaml_data)  # b\"'1': 2\\n'3': 4\\n\"<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>msgspec.{format}.[encode\/decode]<\/code>, \u0433\u0434\u0435 format \u044d\u0442\u043e <code>json<\/code>, <code>yaml<\/code>, <code>toml<\/code>, <code>msgpack<\/code>.<\/p>\n<h2>\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044f\u0441\u044c \u043e\u0442 <code>msgspec.Struct<\/code>, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043a\u0430\u043a \u0432 attrs\/dataclsses\/pydantic.<\/p>\n<pre><code class=\"python\">class User(msgspec.Struct):     name: str     surname: str     email: str | None = None   print(msgspec.json.decode(b'{\"name\":\"vasya\",\"surname\":\"pupkin\"}', type=User)) # User(name='vasya', surname='pupkin', email=None)  print(msgspec.json.decode(b'{\"name\":\"vasya\",\"surname\":123}', type=User)) # print(msgspec.json.decode(b'{\"name\":\"vasya\",\"surname\":123}', type=User)) #       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # msgspec.ValidationError: Expected `str`, got `int` - at `$.surname`<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>type<\/code> , \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0445\u0435\u043c\u0443.<\/p>\n<h2>\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438<\/h2>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c msgspec \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0441 \u0441\u0430\u043c\u044b\u043c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u0442\u044b\u0441\u044f\u0447\u0443 \u0440\u0430\u0437, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"json\">tests = [     # JSON     {         \"msgspec.json.decode(data)\": {\"data\": json_text},         \"json.loads(data)\": {\"data\": json_text},     },     {         \"msgspec.json.encode(data)\": {\"data\": json_data},         \"json.dumps(data)\": {\"data\": json_data},     },     {         \"msgspec.json.decode(data)\": {\"data\": json_text},         \"orjson.loads(data)\": {\"data\": json_text},     },     {         \"msgspec.json.encode(data)\": {\"data\": json_data},         \"orjson.dumps(data)\": {\"data\": json_data},     },     # TOML     {         \"msgspec.toml.decode(data)\": {\"data\": toml_text},         \"toml.loads(data)\": {\"data\": toml_text},     },     {         \"msgspec.toml.decode(data)\": {\"data\": toml_text},         \"tomllib.loads(data)\": {\"data\": toml_text},     },     {         \"msgspec.toml.encode(data)\": {\"data\": toml_data},         \"toml.dumps(data)\": {\"data\": toml_data},     },     # YAML     {         \"msgspec.yaml.decode(data)\": {\"data\": yaml_text},         \"yaml.load(data, Loader=yaml.Loader)\": {             \"data\": yaml_text,         },     },     {         \"msgspec.yaml.decode(data)\": {\"data\": yaml_text},         \"yaml.load(data, Loader=yaml.CLoader)\": {             \"data\": yaml_text,         },     },     {         \"msgspec.yaml.encode(data)\": {\"data\": yaml_data},         \"yaml.dump(data, Dumper=yaml.Dumper)\": {             \"data\": yaml_data,         },     },     {         \"msgspec.yaml.encode(data)\": {\"data\": yaml_data},         \"yaml.dump(data, Dumper=yaml.CDumper)\": {             \"data\": yaml_data,         },     }, ]<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">\u0422\u0435\u0441\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">Msgspec (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">json.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">707.8           <\/p>\n<\/td>\n<td>\n<p align=\"left\">315.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">json.dumps(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">946.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">118.6<\/p>\n<\/td>\n<td>\n<p align=\"left\">8.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">orjson.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">306.2<\/p>\n<\/td>\n<td>\n<p align=\"left\">315.7<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">orjson.dumps(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">83.9<\/p>\n<\/td>\n<td>\n<p align=\"left\">118.2<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.7<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">toml.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,017.9<\/p>\n<\/td>\n<td>\n<p align=\"left\">420.0<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">tomllib.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">420.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">420.2<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">toml.dumps(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">154.0<\/p>\n<\/td>\n<td>\n<p align=\"left\">170.3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.load(data, Loader=yaml.Loader)<\/p>\n<\/td>\n<td>\n<p align=\"left\">16,142.7<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,602.5<\/p>\n<\/td>\n<td>\n<p align=\"left\">10.1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.load(data, Loader=yaml.CLoader)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,625.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,603.1<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.dump(data, Dumper=yaml.Dumper)<\/p>\n<\/td>\n<td>\n<p align=\"left\">10,032.0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,595.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">6.3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.dump(data, Dumper=yaml.CDumper)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,600.5<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,594.8<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0430\u0440\u0441\u0435\u0440\u044b. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e json, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, orjson), \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0440\u0430\u0437\u043d\u044f\u0442\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 yaml msgspec \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 C \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, <a href=\"https:\/\/github.com\/jcrist\/msgspec\/?tab=readme-ov-file\" rel=\"noopener noreferrer nofollow\">\u0435\u0441\u0442\u044c<\/a> \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 yaml, \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 API, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0434\u0430\u0451\u0442 json \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u0430 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c pydanti\u0441, \u0442\u043e \u0432\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c msgspec. \u0422\u0430\u043a\u0436\u0435 \u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0435\u0441\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 json \u0441\u0445\u0435\u043c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/830098\/\"> https:\/\/habr.com\/ru\/articles\/830098\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a\u0438\u043c\u0438 \u043a\u0430\u043a JSON, TOML, YAML \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438.<\/p>\n<p><code>msgspec<\/code>\u00a0\u2014 \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u044d\u0442\u0438\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c\u00a0\u0431\u044b\u0442\u044c\u00a0\u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0414\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u043e\u0434\u0438\u043d \u0438\u043c\u043f\u043e\u0440\u0442, \u0447\u0442\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0432\u0430\u043c.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u0434\u0435\u0440\u044b\/\u0434\u0435\u043a\u043e\u0434\u0435\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432: JSON, MessagePack, YAML \u0438 TOMI. <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 <\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 (\u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 attrs\/pydantic, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435)<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<pre><code class=\"bash\"> pip3 install \"msgspec[toml,yaml]\"<\/code><\/pre>\n<p>\u0411\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 json \u0438 messagepack.<\/p>\n<h2>\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \/ \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u0435\u043d \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">import msgspec  a = {\"1\": 2, \"3\": 4} encoded_json_data = msgspec.json.encode(a) print(encoded_json_data)  # b'{\"1\": 2, \"3\": 4}'  decoded_data = msgspec.json.decode(encoded_json_data) print(decoded_data)  # {'1': 2, '3': 4}  yaml_data = msgspec.yaml.encode(a) print(yaml_data)  # b\"'1': 2\\n'3': 4\\n\"<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>msgspec.{format}.[encode\/decode]<\/code>, \u0433\u0434\u0435 format \u044d\u0442\u043e <code>json<\/code>, <code>yaml<\/code>, <code>toml<\/code>, <code>msgpack<\/code>.<\/p>\n<h2>\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0414\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044f\u0441\u044c \u043e\u0442 <code>msgspec.Struct<\/code>, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u043a\u0430\u043a \u0432 attrs\/dataclsses\/pydantic.<\/p>\n<pre><code class=\"python\">class User(msgspec.Struct):     name: str     surname: str     email: str | None = None   print(msgspec.json.decode(b'{\"name\":\"vasya\",\"surname\":\"pupkin\"}', type=User)) # User(name='vasya', surname='pupkin', email=None)  print(msgspec.json.decode(b'{\"name\":\"vasya\",\"surname\":123}', type=User)) # print(msgspec.json.decode(b'{\"name\":\"vasya\",\"surname\":123}', type=User)) #       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # msgspec.ValidationError: Expected `str`, got `int` - at `$.surname`<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>type<\/code> , \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0445\u0435\u043c\u0443.<\/p>\n<h2>\u0411\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438<\/h2>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c msgspec \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0441 \u0441\u0430\u043c\u044b\u043c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0435\u0440\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u0442\u044b\u0441\u044f\u0447\u0443 \u0440\u0430\u0437, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f<\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"json\">tests = [     # JSON     {         \"msgspec.json.decode(data)\": {\"data\": json_text},         \"json.loads(data)\": {\"data\": json_text},     },     {         \"msgspec.json.encode(data)\": {\"data\": json_data},         \"json.dumps(data)\": {\"data\": json_data},     },     {         \"msgspec.json.decode(data)\": {\"data\": json_text},         \"orjson.loads(data)\": {\"data\": json_text},     },     {         \"msgspec.json.encode(data)\": {\"data\": json_data},         \"orjson.dumps(data)\": {\"data\": json_data},     },     # TOML     {         \"msgspec.toml.decode(data)\": {\"data\": toml_text},         \"toml.loads(data)\": {\"data\": toml_text},     },     {         \"msgspec.toml.decode(data)\": {\"data\": toml_text},         \"tomllib.loads(data)\": {\"data\": toml_text},     },     {         \"msgspec.toml.encode(data)\": {\"data\": toml_data},         \"toml.dumps(data)\": {\"data\": toml_data},     },     # YAML     {         \"msgspec.yaml.decode(data)\": {\"data\": yaml_text},         \"yaml.load(data, Loader=yaml.Loader)\": {             \"data\": yaml_text,         },     },     {         \"msgspec.yaml.decode(data)\": {\"data\": yaml_text},         \"yaml.load(data, Loader=yaml.CLoader)\": {             \"data\": yaml_text,         },     },     {         \"msgspec.yaml.encode(data)\": {\"data\": yaml_data},         \"yaml.dump(data, Dumper=yaml.Dumper)\": {             \"data\": yaml_data,         },     },     {         \"msgspec.yaml.encode(data)\": {\"data\": yaml_data},         \"yaml.dump(data, Dumper=yaml.CDumper)\": {             \"data\": yaml_data,         },     }, ]<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">\u0422\u0435\u0441\u0442<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">Msgspec (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">json.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">707.8           <\/p>\n<\/td>\n<td>\n<p align=\"left\">315.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">json.dumps(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">946.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">118.6<\/p>\n<\/td>\n<td>\n<p align=\"left\">8.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">orjson.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">306.2<\/p>\n<\/td>\n<td>\n<p align=\"left\">315.7<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">orjson.dumps(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">83.9<\/p>\n<\/td>\n<td>\n<p align=\"left\">118.2<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.7<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">toml.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,017.9<\/p>\n<\/td>\n<td>\n<p align=\"left\">420.0<\/p>\n<\/td>\n<td>\n<p align=\"left\">2.4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">tomllib.loads(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">420.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">420.2<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">toml.dumps(data)<\/p>\n<\/td>\n<td>\n<p align=\"left\">154.0<\/p>\n<\/td>\n<td>\n<p align=\"left\">170.3<\/p>\n<\/td>\n<td>\n<p align=\"left\">0.9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.load(data, Loader=yaml.Loader)<\/p>\n<\/td>\n<td>\n<p align=\"left\">16,142.7<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,602.5<\/p>\n<\/td>\n<td>\n<p align=\"left\">10.1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.load(data, Loader=yaml.CLoader)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,625.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,603.1<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.dump(data, Dumper=yaml.Dumper)<\/p>\n<\/td>\n<td>\n<p align=\"left\">10,032.0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,595.4<\/p>\n<\/td>\n<td>\n<p align=\"left\">6.3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"318\" width=\"318\">\n<p align=\"left\">yaml.dump(data, Dumper=yaml.CDumper)<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,600.5<\/p>\n<\/td>\n<td>\n<p align=\"left\">1,594.8<\/p>\n<\/td>\n<td>\n<p align=\"left\">1.0<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0430\u0440\u0441\u0435\u0440\u044b. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e json, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, orjson), \u043d\u043e \u0432\u0441\u0435 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0440\u0430\u0437\u043d\u044f\u0442\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 yaml msgspec \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 C \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, <a href=\"https:\/\/github.com\/jcrist\/msgspec\/?tab=readme-ov-file\" rel=\"noopener noreferrer nofollow\">\u0435\u0441\u0442\u044c<\/a> \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 yaml, \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 API, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0434\u0430\u0451\u0442 json \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u0430 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c pydanti\u0441, \u0442\u043e \u0432\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c msgspec. \u0422\u0430\u043a\u0436\u0435 \u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0435\u0441\u0442\u044c \u043f\u043b\u044e\u0448\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 json \u0441\u0445\u0435\u043c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/830098\/\"> https:\/\/habr.com\/ru\/articles\/830098\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-426694","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/426694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=426694"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/426694\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=426694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=426694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=426694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}