{"id":495452,"date":"2026-09-21T14:18:11","date_gmt":"2026-09-21T14:18:11","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=495452"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=495452","title":{"rendered":"\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c Python \u043a\u043e\u0434 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043d\u0430 Rust c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/github.com\/pyo3\/pyo3\" rel=\"noopener nofollow\">PyO3<\/a>. \u041d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0430 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0443\u044e\u0442\u043d\u044b\u0439 \u043c\u0438\u0440 Python &#8212; \u043d\u0435\u0442, \u0435\u0441\u0442\u044c <a href=\"https:\/\/mypyc.readthedocs.io\/en\/latest\/introduction.html\" rel=\"noopener nofollow\">mypyc<\/a>.<\/p>\n<blockquote>\n<p><strong>TLDR<\/strong>: \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/python-hyper\/h11\" rel=\"noopener nofollow\">h11<\/a> (HTTP\/1.1 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430 \u0441\u043e 710k \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 Github) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 mypyc \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044f \u0447\u0438\u043d\u0438\u043b \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 c \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u043f\u043e\u0434 mypyc.<\/p>\n<\/blockquote>\n<p>\u041a\u043e\u0434 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u043c\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 Github: <a href=\"https:\/\/github.com\/danfimov\/h11\" rel=\"noopener nofollow\">danfimov\/h11<\/a>.<\/p>\n<h3>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0430\u0437\u0430<\/h3>\n<p>\u041f\u0440\u043e <a href=\"https:\/\/mypy.readthedocs.io\/en\/stable\/\" rel=\"noopener nofollow\">mypy<\/a> \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u0441\u0435 (\u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0442\u043e\u0436\u0435), \u0430 \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u043e\u0435 mypyc? Mypyc \u2014 \u044d\u0442\u043e ahead of time \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f\u0430\u043c\u0438 Python-\u043a\u043e\u0434 \u0432 CPython C-extensions. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043d\u0430 \u043f\u0430\u043b\u044c\u0446\u0430\u0445, \u0442\u043e mypyc \u0431\u0435\u0440\u0435\u0442 \u0432\u0430\u0448 Python-\u043a\u043e\u0434 \u0438, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u044b <code>.so<\/code> \u0438\u043b\u0438 <code>.pyd<\/code> (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b). \u0412 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c C\u2011extension \u043a\u043e\u0434, \u043f\u0440\u0438\u0447\u0435\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c. \u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c CPython \u043a\u043e\u0434 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0445\u043e\u0434\u0443, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 \u043a\u043e\u0434 &#8212; \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c Python-\u043a\u043e\u0434\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u044b, \u0447\u0442\u043e\u0431\u044b:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00abunboxed\u00bb \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430). \u0423\u0441\u043b\u043e\u0432\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>PyObject<\/code> \u0434\u043b\u044f integer \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 <code>int32_t<\/code> \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 C;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0430\u0442\u044c early binding (\u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438);<\/p>\n<\/li>\n<li>\n<p>\u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 lookup\u2019\u0438 \u0432 \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0430\u0445. \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443: \u043f\u0440\u043e\u0439\u0434\u0438\u0441\u044c \u043f\u043e <code>__dict__<\/code>, \u043f\u043e\u0442\u043e\u043c \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0430\u043c (MRO), \u043f\u043e\u0442\u043e\u043c \u0443\u0447\u0442\u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b, <code>__getattribute__<\/code>, <code>__getattr__<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a \u043a\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u044f\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0430\u0434\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u0447\u0435\u043c \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e Python \u043a\u043e\u0434\u0430 mypyc \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044f\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c <code>TypeError<\/code> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<h3>\u0427\u0438\u043d\u0438\u043c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0447\u0435\u0440\u0435\u0437 mypyc, \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442 mypy. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043cypy, \u043a\u043b\u0430\u0434\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 <code>pyproject.toml<\/code> \u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c:<\/p>\n<pre><code>[tool.mypy]strict = truewarn_unused_configs = truewarn_unused_ignores = trueshow_error_codes = true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041e\u0446\u0435\u043d\u0438\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 h11:<\/p>\n<pre><code class=\"bash\">&gt; mypy h11...Found 13 errors in 3 files (checked 11 source files)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u043d\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u043e, \u043f\u0430\u0440\u0430 \u043b\u0438\u0448\u043d\u0438\u0445 <code># type: ignore<\/code> \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u043e\u0432. \u041d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430 \u043d\u0435\u043c\u043e\u043b\u043e\u0434\u0430\u044f, \u043f\u043b\u044e\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 Python \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e 3.8. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0443\u043f\u0430\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f c back compatibility, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u0441\u0438\u044e mypy (2.3.1) \u0438 \u0431\u0443\u0434\u0435\u043c \u0447\u0438\u043d\u0438\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c Python 3.10+ (\u0432\u0441\u0435 \u043d\u0435 EOL \u0440\u0435\u043b\u0438\u0437\u044b).<\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 \u0442\u0440\u0438 \u044d\u0442\u0430\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u0423\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c mypy \u0438 \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0432 strict \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b mypyc \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 (\u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442).<\/p>\n<\/li>\n<\/ul>\n<h4>bytes vs bytearray \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/h4>\n<p>\u041f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 mypy. <code>ReceiveBuffer.maybe_extract_lines()<\/code> <a href=\"https:\/\/github.com\/python-hyper\/h11\/blob\/62c5068c971579d61fa1b55373390e12f25fd856\/h11\/_receivebuffer.py#L104\" rel=\"noopener nofollow\">\u043c\u0435\u0442\u043e\u0434<\/a> \u0438 <code>maybe_extract_at_most()<\/code> <a href=\"https:\/\/github.com\/python-hyper\/h11\/blob\/62c5068c971579d61fa1b55373390e12f25fd856\/h11\/_receivebuffer.py#L77\" rel=\"noopener nofollow\">\u043c\u0435\u0442\u043e\u0434<\/a> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 <code>bytearray<\/code> (\u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437). \u0410 <code>_obsolete_line_fold<\/code>, <code>_decode_header_lines<\/code>, <code>validate()<\/code>, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Data()<\/code> \u0431\u044b\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a\u0430\u043a \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 <code>bytes<\/code>. \u041e\u0442\u0441\u044e\u0434\u0430 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 mypy:<\/p>\n<pre><code class=\"bash\">h11\/_readers.py:53: error: Incompatible types in assignment (expression has type \"bytearray\", variable has type \"bytes | None\")  [assignment]h11\/_readers.py:84: error: Argument 2 to \"validate\" has incompatible type \"bytearray\"; expected \"bytes\"  [arg-type]h11\/_readers.py:87: error: Argument 1 to \"_decode_header_lines\" has incompatible type \"list[bytearray]\"; expected \"Iterable[bytes]\"  [arg-type]h11\/_readers.py:104: error: Argument 2 to \"validate\" has incompatible type \"bytearray\"; expected \"bytes\"  [arg-type]h11\/_readers.py:114: error: Argument 1 to \"_decode_header_lines\" has incompatible type \"list[bytearray]\"; expected \"Iterable[bytes]\"  [arg-type]h11\/_readers.py:134: error: Argument \"data\" to \"Data\" has incompatible type \"bytearray\"; expected \"bytes\"  [arg-type]h11\/_readers.py:161: error: Argument 1 to \"_decode_header_lines\" has incompatible type \"list[bytearray]\"; expected \"Iterable[bytes]\"  [arg-type]h11\/_readers.py:182: error: Argument 2 to \"validate\" has incompatible type \"bytearray\"; expected \"bytes\"  [arg-type]h11\/_readers.py:204: error: Argument \"data\" to \"Data\" has incompatible type \"bytearray\"; expected \"bytes\"  [arg-type]h11\/_readers.py:218: error: Argument \"data\" to \"Data\" has incompatible type \"bytearray\"; expected \"bytes\"  [arg-type]<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b  \u0432 <code>_obsolete_line_fold<\/code>, <code>_decode_header_lines<\/code>, <code>validate()<\/code> \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 <code>Data()<\/code> \u0434\u043e <code>bytes | bytearray<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e <code>bytes<\/code>. \u0412 \u043e\u0431\u0449\u0435\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c, \u0433\u0434\u0435 \u0431\u0430\u0439\u0442\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0434\u0451\u0442 \u0438\u0437 <code>ReceiveBuffer<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 API, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u0447\u0438\u0441\u0442\u044b\u0439 <code>bytes<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0437\u0430\u0432\u0435\u043b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0438 \u0432\u0435\u0437\u0434\u0435 \u043f\u0440\u043e\u0440\u0430\u0441\u0442\u0438\u043b \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\"># _util.pyByteLike = Union[bytes, bytearray]def validate(regex, data: ByteLike, ...) -&gt; Dict[str, bytes]: ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0442 \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442 <code>method<\/code>\/<code>target<\/code>\/<code>http_version<\/code>\/<code>reason<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/python-hyper\/h11\/blob\/62c5068c971579d61fa1b55373390e12f25fd856\/h11\/_events.py#L77\" rel=\"noopener nofollow\">\u0442\u0443\u0442<\/a>) \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 <code>Request<\/code>\/<code>_ResponseBase<\/code> &#8212; \u0442\u0430\u043c \u0432 \u0442\u0438\u043f\u0430\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u044b <code>bytes<\/code>, \u043d\u043e \u0441\u0443\u0434\u044f \u043f\u043e \u0442\u0435\u0441\u0442\u0430\u043c, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 <code>bytearray<\/code>. \u0417\u0430\u043c\u0435\u043d\u0438\u043c.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u043f\u0440\u0430\u0432\u043e\u043a \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 <code># type: ignore<\/code> \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 mypy \u0447\u0438\u0441\u0442. \u0417\u043d\u0430\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e, \u0447\u0442\u043e \u043a\u043e\u0434 \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f mypyc? \u041f\u043e\u043a\u0430 \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043d\u0435\u0442. \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>mypyc h11 --exclude 'h11\/tests\/'<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0443\u0447\u0430 \u043e\u0448\u0438\u0431\u043e\u043a. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<h4>\u0427\u0438\u043d\u0438\u043c \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441 Sentinel<\/h4>\n<p>\u0412 <a href=\"https:\/\/github.com\/python-hyper\/h11\/blob\/62c5068c971579d61fa1b55373390e12f25fd856\/h11\/_util.py#L107\" rel=\"noopener nofollow\">h11\/_util.py<\/a> \u0435\u0441\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"python\">class Sentinel(type):    def __new__(cls, name, bases, namespace, **kwds):        assert bases == (Sentinel,)        v = super().__new__(cls, name, bases, namespace, **kwds)        v.__class__ = v  # \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043e \u0431\u044b\u043b\u043e \u043f\u0438\u0441\u0430\u0442\u044c type(sentinel) is sentinel        return v    def __repr__(self):        return self.__name__class IDLE(Sentinel, metaclass=Sentinel):    pass<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 (sentinel-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439), \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>CLIENT<\/code>, <code>SERVER<\/code>, <code>IDLE<\/code>, <code>DONE<\/code>, <code>NEED_DATA<\/code>, <code>PAUSED<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>mypyc \u0441\u043f\u043e\u0442\u044b\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b:<\/p>\n<pre><code class=\"bash\">h11\/_util.py:112: error: Inheriting from most builtin types is unimplementednote: Potential workaround: @mypy_extensions.mypyc_attr(native_class=False)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438\u043a\u043e\u043b \u0441 <code>v.__class__ = v<\/code>, \u0434\u0430\u044e\u0449\u0438\u0439 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0435\u043d\u0442\u0438\u043d\u0435\u043b\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0432\u0440\u043e\u0434\u0435 <code>type(IDLE) is IDLE<\/code>, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u043c \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e \u0441\u043e\u0432\u0435\u0442\u0443 \u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043e\u0442 mypyc \u043d\u0430\u0432\u0435\u0441\u0438\u0442\u044c <code>@mypyc_attr(native_class=False)<\/code> \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0436\u0438\u0442\u044c. \u042d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u00ab\u043d\u0435 \u043f\u044b\u0442\u0430\u0439\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 C-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 Python-\u043a\u043b\u0430\u0441\u0441\u00bb. \u0418\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432: \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f runtime \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 <code>mypy_extensions<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0431\u0435\u043d\u0435\u0444\u0438\u0442\u043e\u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c Sentinel \u0432 \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e <code>class IDLE(Sentinel)<\/code>, \u0437\u0430\u0431\u0438\u0432 \u043d\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 <code>__repr__<\/code> \u0438 <code>type(sentinel) is sentinel<\/code>. \u0414\u0443\u043c\u0430\u044e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438, \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0438\u043c\u043e (\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 MR \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0442\u043e \u0442\u0443\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0430\u0434\u043e).<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 + \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0441 <code>__repr__<\/code> = \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043f\u043e\u0447\u0438\u043d\u0438\u043b\u0438. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u0436\u0435 mypyc \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u0432\u0430\u043c \u043a\u043e\u0434, \u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f <code>.so<\/code> \u0444\u0430\u0439\u043b\u044b. \u0417\u043d\u0430\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a? \u0416\u0430\u043b\u044c, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442\u2026<\/p>\n<h4>Event(ABC) + \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e slots \u043d\u0430 dataclasses<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0442\u043e \u0432\u044b\u043b\u0435\u0437\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code class=\"python\">import h11print(h11.Event)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<pre><code class=\"bash\">&gt; uv run python -m test_scriptTraceback (most recent call last):  File \"&lt;frozen runpy&gt;\", line 198, in _run_module_as_main  File \"&lt;frozen runpy&gt;\", line 88, in _run_code  File \"\/home\/danfimov\/Documents\/projects\/h11-mypyc\/a.py\", line 1, in &lt;module&gt;    import h11  File \"h11\/__init__.py\", line 9, in &lt;module&gt;    from h11._connection import Connection, NEED_DATA, PAUSED  File \"h11\/_connection.py\", line 16, in &lt;module&gt;    from ._events import (  File \"h11\/_events.py\", line 41, in &lt;module&gt;    class Request(Event):AttributeError: type object 'Request' has no attribute '__slots__'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0434\u0432\u0443\u0445 \u0432\u0435\u0449\u0435\u0439: <code>Event<\/code> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <code>abc.ABC<\/code>, <code>Request<\/code>\/<code>Response<\/code>\/\u2026 \u2014 \u0437\u0430\u043c\u043e\u0440\u043e\u0436\u0435\u043d\u043d\u044b\u0435 <code>@dataclass(init=False, frozen=True)<\/code> \u0441 \u0440\u0443\u0447\u043d\u044b\u043c <code>__slots__ = (...)<\/code> \u0432 \u0442\u0435\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c Python \u044d\u0442\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 mypyc \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u043a\u0430\u043a \u201c\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435\u201d (\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f C, <code>PyTypeObject<\/code>), \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u043e\u0442\u044b \u0443\u0436\u0435 \u0437\u0430\u0448\u0438\u0442\u044b \u0432 layout \u2014 \u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0441 ABC-\u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u0430\u0451\u0442 <code>AttributeError<\/code> \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c Event \u043e\u0442 ABC \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0442\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e:<\/p>\n<pre><code class=\"python\"># \u0431\u044b\u043b\u043eclass Event(ABC):    __slots__ = ()@dataclass(init=False, frozen=True)class Request(Event):    __slots__ = (\"method\", \"headers\", \"target\", \"http_version\")    ...# \u0441\u0442\u0430\u043b\u043eclass Event:    pass@dataclass(init=False, frozen=True, slots=True)class Request(Event):    ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u0437 Request\/Response \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 <code>super().__init__()<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u043c\u0430\u0435\u0442 \u0434\u0430\u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 python \u043a\u043e\u0434.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430:<\/p>\n<pre><code class=\"bash\">Traceback (most recent call last):  File \"&lt;frozen runpy&gt;\", line 198, in _run_module_as_main  File \"&lt;frozen runpy&gt;\", line 88, in _run_code  File \"\/home\/danfimov\/Documents\/projects\/h11-mypyc\/a.py\", line 1, in &lt;module&gt;    import h11  File \"h11\/__init__.py\", line 9, in &lt;module&gt;    from h11._connection import Connection, NEED_DATA, PAUSED  File \"h11\/_connection.py\", line 26, in &lt;module&gt;    from ._readers import READERS, ReadersType  File \"h11\/_readers.py\", line 25, in &lt;module&gt;    from ._state import (  File \"h11\/_state.py\", line 115, in &lt;module&gt;    from ._events import *ModuleNotFoundError: No module named '_events'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0427\u0438\u043d\u0438\u0442\u0441\u044f \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435 &#8212; \u043d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>from ._events import *<\/code> \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u044f\u0432\u043d\u044b\u0439:<\/p>\n<pre><code class=\"python\">from ._events import (    ConnectionClosed, Data, EndOfMessage, Event,    InformationalResponse, Request, Response,)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0438\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"bash\">&gt; uv run python -m test_script&lt;class 'h11._events.Event'&gt;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0416\u0430\u043b\u044c, \u0447\u0442\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0432\u0430\u043b\u0438\u0442\u0441\u044f c <code>TypeError<\/code>:<\/p>\n<pre><code class=\"bash\">FAILED h11\/tests\/test_against_stdlib_http.py::test_h11_as_client - TypeError: bytes object expected; got bytearrayFAILED h11\/tests\/test_connection.py::test__body_framing - TypeError: bytes object expected; got NoneFAILED h11\/tests\/test_connection.py::test_Connection_basics_and_content_length - TypeError: bytes object expected; got bytearrayFAILED h11\/tests\/test_connection.py::test_chunked - TypeError: bytes object expected; got bytearrayFAILED h11\/tests\/test_connection.py::test_chunk_boundaries - TypeError: bytes object expected; got bytearrayFAILED h11\/tests\/test_connection.py::test_client_talking_to_http10_server - TypeError: bytes object expected; got bytearray...23 failed, 55 passed in 0.30s<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u041c\u043e\u0436\u0435\u0442 Any \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u043f\u043b\u043e\u0445?<\/h4>\n<p>\u041a\u0430\u043a \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0440\u0430\u043d\u0435\u0435, mypyc \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044f\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c <code>TypeError<\/code> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u042d\u0442\u043e \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\">    def test_normalize_data_events() -&gt; None:        assert normalize_data_events(            [&gt;               Data(data=bytearray(b\"1\")),                ^^^^^^^^^^^^^^^^^^^^^^^^^^                Data(data=b\"2\"),                Response(status_code=200, headers=[]),                Data(data=b\"3\"),                Data(data=b\"4\"),                EndOfMessage(),                Data(data=b\"5\"),                Data(data=b\"6\"),                Data(data=b\"7\"),            ]        ) == [            Data(data=b\"12\"),            Response(status_code=200, headers=[]),            Data(data=b\"34\"),            EndOfMessage(),            Data(data=b\"567\"),        ]h11\/tests\/test_helpers.py:8:_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ &gt;   object.__setattr__(self, \"data\", data)E   TypeError: bytes object expected; got bytearrayh11\/_events.py:293: TypeError<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>data<\/code> \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e <code>bytearray<\/code>. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0438\u043f \u0434\u043b\u044f <code>Data.data<\/code> \u0443\u043a\u0430\u0437\u0430\u043d \u043a\u0430\u043a <code>bytes<\/code>, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>TypeError<\/code> \u0434\u043b\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <code>Data.data<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>bytes<\/code>, \u043d\u043e \u0438 \u00ab\u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u043c\u0435\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0438 \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e <code>len()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0431\u0430\u0439\u0442\u00bb &#8212; \u044d\u0442\u043e \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 <code>sendfile()<\/code>-\u0437\u0430\u0433\u043b\u0443\u0448\u0435\u043a. \u041c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0434\u043e <code>bytes | bytearray<\/code>, \u043d\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c <code>Any<\/code> (\u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432). \u041c\u0435\u043d\u044f\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e \u0437\u0434\u0435\u0441\u044c \u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u0433\u0434\u0435 \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f (\u0441\u043c. send_data \u043c\u0435\u0442\u043e\u0434) \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c &#8212; \u0442\u0435\u0441\u0442 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u0442.<\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441 <code>_ResponseBase.status_code<\/code>. \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 <code>isinstance(status_code, int)<\/code> \u0438 \u043a\u0438\u0434\u0430\u0435\u0442 <code>LocalProtocolError(\"status code must be integer\")<\/code>, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u0432 API \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u0434\u0440\u0443\u0436\u0435\u043b\u044e\u0431\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u043b\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u041f\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u0430\u043a <code>status_code: int<\/code>, mypyc \u0441\u0430\u043c \u043a\u0438\u0434\u0430\u0435\u0442 <code>TypeError<\/code> \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2014 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0430\u0434\u0430\u0435\u0442. \u041f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0442\u043e\u0436\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0434\u043e <code>Any<\/code>.<\/p>\n<h4>\u0412\u044b\u0447\u0438\u0449\u0430\u0435\u043c \u043b\u0438\u0448\u043d\u0438\u0435 None<\/h4>\n<p>\u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">&gt;   reason = b\"\" if matches[\"reason\"] is None else matches[\"reason\"]E   TypeError: bytes object expected; got None<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>status_line<\/code> \u0432 ABNF \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 <code>reason<\/code> \u0438 <code>http_version<\/code> (\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0448\u043b\u044e\u0442 <code>HTTP\/1.0 200\\r\\n<\/code> \u0431\u0435\u0437 \u0444\u0440\u0430\u0437\u044b). <code>match.groupdict()<\/code> \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043b\u0430\u0434\u0451\u0442 <code>None<\/code> \u0432 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0432\u0448\u0443\u044e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0443. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <code>def validate(...) -&gt; Dict[str, bytes]<\/code>, \u0447\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0434\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e -\u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043c\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <code>None<\/code>. mypyc \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u2014 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e <code>bytes<\/code>, \u0438 \u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 <code>return match.groupdict()<\/code>. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0444\u0438\u043a\u0441\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0449\u0430\u0442\u044c \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0432\u0448\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0435\u0440\u0435\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043e\u043c:<\/p>\n<pre><code class=\"python\">def validate(regex, data: ByteLike, msg=\"malformed data\", *format_args) -&gt; Dict[str, bytes]:    match = regex.fullmatch(data)    if not match:        ...        raise LocalProtocolError(msg)    return {name: value for name, value in match.groupdict().items() if value is not None}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u2014 \u0447\u0438\u0442\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0447\u0435\u0440\u0435\u0437 <code>.get(name, default)<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>matches[name] is None<\/code>:<\/p>\n<pre><code class=\"python\">http_version = matches.get(\"http_version\", b\"1.1\")reason = matches.get(\"reason\", b\"\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0423\u0431\u0438\u0440\u0430\u0435\u043c cast<\/h4>\n<p>\u0422\u0435\u0441\u0442\u044b \u0432 <code>test_connection.py<\/code> \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>type: ignore<\/code>, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u0438\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">assert _body_framing(None, req()) == (\"content-length\", (0,))  # type: ignore<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>Connection._request_method<\/code> \u2014 \u044d\u0442\u043e <code>Optional[bytes]<\/code>: \u0434\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0430 <code>Request<\/code> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <code>408 Request Timeout<\/code> \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b) \u043c\u0435\u0442\u043e\u0434\u0430 \u0435\u0449\u0451 \u043d\u0435\u0442. \u0412 h11 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u0440\u044f\u0442\u0430\u043b \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 <code>cast(bytes, self._request_method)<\/code> \u2014 \u043c\u043e\u043b, \u201c\u0434\u043e\u0432\u0435\u0440\u044c\u0442\u0435\u0441\u044c \u043c\u043d\u0435, \u0442\u0443\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 None\u201d. \u0412 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 <code>cast()<\/code> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0430\u0451\u0442 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 (\u044d\u0442\u043e \u0447\u0438\u0441\u0442\u043e mypy-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430), \u0430 <code>_body_framing<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f <code>bytes<\/code> \u2014 \u043f\u0430\u0434\u0430\u0435\u0442 <code>TypeError<\/code> \u043d\u0430 \u0436\u0438\u0432\u043e\u043c 408-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0438\u043a\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u044f\u0432\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c <code>Optional[bytes]<\/code>:<\/p>\n<pre><code class=\"python\">def _body_framing(request_method: Optional[bytes], event: Union[Request, Response]):    ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><code>None<\/code> \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (<code>== b\"HEAD\"<\/code>, <code>== b\"GET\"<\/code>) \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0438 \u0441\u043d\u044f\u0442\u0438\u0435 <code>cast()<\/code>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u043e\u0439\u0434\u0443\u0442.<\/p>\n<h3>\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0434\u0430\u0435\u0442 \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a: \u0440\u0430\u0437\u0431\u043e\u0440 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u043b\u0438\u043d\u043d\u0443\u044e \u043a\u0443\u043a\u0443, \u043f\u043b\u044e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 1000 \u0431\u0430\u0439\u0442.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0412\u0435\u0440\u0441\u0438\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041c\u0435\u0434\u0438\u0430\u043d\u0430, req\/sec<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e baseline<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>h11<\/code>, \u0434\u043e \u043f\u0440\u0430\u0432\u043e\u043a<\/p>\n<\/td>\n<td>\n<p align=\"left\">36 414<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>h11<\/code>, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u043e\u043a, \u0447\u0438\u0441\u0442\u044b\u0439 Python<\/p>\n<\/td>\n<td>\n<p align=\"left\">37 409<\/p>\n<\/td>\n<td>\n<p align=\"left\">+2%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><code>h11<\/code>, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u043e\u043a \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">58 983<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>+62%<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u043e\u043a \u043d\u0435 \u043f\u0440\u043e\u0441\u0435\u043b\u0430 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (+2% &#8212; \u044d\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0448\u0443\u043c\u0430 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0430). \u041d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0434\u0430\u043b\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0431\u0443\u0441\u0442. \u0414\u0430, \u043d\u0435 \u043a\u043b\u0438\u043a\u0431\u0435\u0439\u0442\u043d\u044b\u0439 x2, \u043d\u043e \u0432\u0441\u0451 \u0435\u0449\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0449\u0443\u0442\u0438\u043c\u044b\u0439.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0438\u0442\u043e\u0433: \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0434\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0444\u0438\u0442, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u043d\u044e\u0430\u043d\u0441\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e mypyc \u043a\u043e\u0434\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 proof-of-concept \u044f \u0444\u043e\u0440\u043a\u043d\u0443\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 h11 \u0438 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b python-\u043f\u0430\u043a\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/danfimov\/h11\" rel=\"noopener nofollow\">\u043a\u043e\u0434 \u0444\u043e\u0440\u043a\u0430<\/a> (\u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u043a\u0438\u043d\u0443\u0442\u044c diff \u0441 \u0430\u043f\u0441\u0442\u0440\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pypi.org\/project\/h11-mypyc\/\" rel=\"noopener nofollow\">h11-mypyc \u043f\u0430\u043a\u0435\u0442 \u043d\u0430 PyPI<\/a><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438 \u043a\u043e\u0434\u0430 \u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430 <a href=\"https:\/\/docs.python.org\/3.15\/whatsnew\/3.15.html#whatsnew315-sampling-profiler\" rel=\"noopener nofollow\">Tachyon<\/a>\/<a href=\"https:\/\/github.com\/bloomberg\/memray\" rel=\"noopener nofollow\">Memray<\/a>. \u0412 \u0444\u043e\u0440\u043a\u0435 \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u043d\u0438\u0445. \u0422\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u0439\u0434\u0435\u0442 \u043e\u0442\u043a\u043b\u0438\u043a, \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u044d\u0442\u043e\u043c\u0443 \u0430\u0441\u043f\u0435\u043a\u0442\u0443.<\/p>\n<\/blockquote>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0441. \u041b\u044e\u0431\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0433\u043e\u0442\u043e\u0432 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<p>\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\/1084776\/\">https:\/\/habr.com\/ru\/articles\/1084776\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 Python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043d\u0430 Rust c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c PyO3. \u041d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0430 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0443\u044e\u0442\u043d\u044b\u0439 \u043c\u0438\u0440 Python &#8212; \u043d\u0435\u0442, \u0435\u0441\u0442\u044c mypyc.TLDR: \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043a\u043e\u0434 h11 (HTTP\/1.1 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430 \u0441\u043e 710k \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 Github) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 mypyc \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044f \u0447\u0438\u043d\u0438\u043b \u0440\u0430\u0437\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 c \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u043f\u043e\u0434 mypyc.\u041a\u043e\u0434 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u043c\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043d\u0430 Github: danfimov\/h11.\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0430\u0437\u0430\u041f\u0440\u043e mypy \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u0441\u0435 (\u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0442\u043e\u0436\u0435), \u0430 \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u043e\u0435 mypyc? Mypyc \u2014 \u044d\u0442\u043e ahead of time \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f\u0430\u043c\u0438 Python-\u043a\u043e\u0434 \u0432 CPython C-extensions. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043d\u0430 \u043f\u0430\u043b\u044c\u0446\u0430\u0445, \u0442\u043e mypyc \u0431\u0435\u0440\u0435\u0442 \u0432\u0430\u0448 Python-\u043a\u043e\u0434 \u0438, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b\u044b .so \u0438\u043b\u0438 .pyd (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b). \u0412 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c C\u2011extension \u043a\u043e\u0434, \u043f\u0440\u0438\u0447\u0435\u043c \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c. \u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c CPython \u043a\u043e\u0434 \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0445\u043e\u0434\u0443, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 \u043a\u043e\u0434 &#8212; \u043e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435.\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c Python-\u043a\u043e\u0434\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u044b, \u0447\u0442\u043e\u0431\u044b:\u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00abunboxed\u00bb \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430). \u0423\u0441\u043b\u043e\u0432\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PyObject \u0434\u043b\u044f integer \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 int32_t \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 C;\u0434\u0435\u043b\u0430\u0442\u044c early binding (\u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438);\u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 lookup\u2019\u0438 \u0432 \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441\u0430\u0445. \u0422\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443: \u043f\u0440\u043e\u0439\u0434\u0438\u0441\u044c \u043f\u043e __dict__, \u043f\u043e\u0442\u043e\u043c \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0430\u043c (MRO), \u043f\u043e\u0442\u043e\u043c \u0443\u0447\u0442\u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b, __getattribute__, __getattr__. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043a \u043a\u0430\u043a\u0438\u043c \u043f\u043e\u043b\u044f\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0430\u0434\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f.\u041f\u0440\u0438\u0447\u0435\u043c \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e Python \u043a\u043e\u0434\u0430 mypyc \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u044f\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c TypeError \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.\u0427\u0438\u043d\u0438\u043c \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0447\u0435\u0440\u0435\u0437 mypyc, \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442 mypy. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043cypy, \u043a\u043b\u0430\u0434\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u0432 pyproject.toml \u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c:[tool.mypy]strict = truewarn_unused_configs = truewarn_unused_ignores = trueshow_error_codes = true\u041e\u0446\u0435\u043d\u0438\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 h11:&gt; mypy h11&#8230;Found 13 errors in 3 files (checked 11 source files)\u0412 \u0446\u0435\u043b\u043e\u043c, \u043d\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u043e, \u043f\u0430\u0440\u0430 \u043b\u0438\u0448\u043d\u0438\u0445 # type: ignore \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u043e\u0432. \u041d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430 \u043d\u0435\u043c\u043e\u043b\u043e\u0434\u0430\u044f, \u043f\u043b\u044e\u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 Python \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e 3.8. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0443\u043f\u0430\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f c back compatibility, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u0441\u0438\u044e mypy (2.3.1) \u0438 \u0431\u0443\u0434\u0435\u043c \u0447\u0438\u043d\u0438\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0430\u043a, \u0431\u0443\u0434\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c Python 3.10+ (\u0432\u0441\u0435 \u043d\u0435 EOL \u0440\u0435\u043b\u0438\u0437\u044b).\u041f\u043e \u0441\u0443\u0442\u0438 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 \u0442\u0440\u0438 \u044d\u0442\u0430\u043f\u0430:\u0423\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u044c mypy \u0438 \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 \u0434\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0432 strict \u0440\u0435\u0436\u0438\u043c\u0435 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438;\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b mypyc \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b;\u0414\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 (\u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0438 \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442).bytes vs bytearray \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432\u041f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 mypy. ReceiveBuffer.maybe_extract_lines() \u043c\u0435\u0442\u043e\u0434 \u0438 maybe_extract_at_most() \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 bytearray (\u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437). \u0410 _obsolete_line_fold, _decode_header_lines, validate(), \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 Data() \u0431\u044b\u043b\u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a\u0430\u043a \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 bytes. \u041e\u0442\u0441\u044e\u0434\u0430 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 mypy:h11\/_readers.py:53: error: Incompatible types in assignment (expression has type &#171;bytearray&#187;, variable has type &#171;bytes | None&#187;)  [assignment]h11\/_readers.py:84: error: Argument 2 to &#171;validate&#187; has incompatible type &#171;bytearray&#187;; expected &#171;bytes&#187;  [arg-type]h11\/_readers.py:87: error: Argument 1 to &#171;_decode_header_lines&#187; has incompatible type &#171;list[bytearray]&#187;; expected &#171;Iterable[bytes]&#187;  [arg-type]h11\/_readers.py:104: error: Argument 2 to &#171;validate&#187; has incompatible type &#171;bytearray&#187;; expected &#171;bytes&#187;  [arg-type]h11\/_readers.py:114: error: Argument 1 to &#171;_decode_header_lines&#187; has incompatible type &#171;list[bytearray]&#187;; expected &#171;Iterable[bytes]&#187;  [arg-type]h11\/_readers.py:134: error: Argument &#171;data&#187; to &#171;Data&#187; has incompatible type &#171;bytearray&#187;; expected &#171;bytes&#187;  [arg-type]h11\/_readers.py:161: error: Argument 1 to &#171;_decode_header_lines&#187; has incompatible type &#171;list[bytearray]&#187;; expected &#171;Iterable[bytes]&#187;  [arg-type]h11\/_readers.py:182: error: Argument 2 to &#171;validate&#187; has incompatible type &#171;bytearray&#187;; expected &#171;bytes&#187;  [arg-type]h11\/_readers.py:204: error: Argument &#171;data&#187; to &#171;Data&#187; has incompatible type &#171;bytearray&#187;; expected &#171;bytes&#187;  [arg-type]h11\/_readers.py:218: error: Argument &#171;data&#187; to &#171;Data&#187; has incompatible type &#171;bytearray&#187;; expected &#171;bytes&#187;  [arg-type]\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b  \u0432 _obsolete_line_fold, _decode_header_lines, validate() \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 Data() \u0434\u043e bytes | bytearray \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e bytes. \u0412 \u043e\u0431\u0449\u0435\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c, \u0433\u0434\u0435 \u0431\u0430\u0439\u0442\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0434\u0451\u0442 \u0438\u0437 ReceiveBuffer \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 API, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0434 \u0447\u0438\u0441\u0442\u044b\u0439 bytes. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0437\u0430\u0432\u0435\u043b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u0438 \u0432\u0435\u0437\u0434\u0435 \u043f\u0440\u043e\u0440\u0430\u0441\u0442\u0438\u043b \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:# _util.pyByteLike = Union[bytes, bytearray]def validate(regex, data: ByteLike, &#8230;) -&gt; Dict[str, bytes]: &#8230;\u0422\u0430\u043a\u0436\u0435 \u043e\u0442 \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442 method\/target\/http_version\/reason (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0443\u0442) \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 Request\/_ResponseBase &#8212; \u0442\u0430\u043c \u0432 \u0442\u0438\u043f\u0430\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u044b bytes, \u043d\u043e \u0441\u0443\u0434\u044f \u043f\u043e \u0442\u0435\u0441\u0442\u0430\u043c, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 bytearray. \u0417\u0430\u043c\u0435\u043d\u0438\u043c.\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u043f\u0440\u0430\u0432\u043e\u043a \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 # type: ignore \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 mypy \u0447\u0438\u0441\u0442. \u0417\u043d\u0430\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e, \u0447\u0442\u043e \u043a\u043e\u0434 \u0443\u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f mypyc? \u041f\u043e\u043a\u0430 \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043d\u0435\u0442. \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c mypyc h11 &#8212;exclude &#8216;h11\/tests\/&#8217; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0443\u0447\u0430 \u043e\u0448\u0438\u0431\u043e\u043a. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0438 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c.\u0427\u0438\u043d\u0438\u043c \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441 Sentinel\u0412 h11\/_util.py \u0435\u0441\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441:class Sentinel(type):    def __new__(cls, name, bases, namespace, **kwds):        assert bases == (Sentinel,)        v = super().__new__(cls, name, bases, namespace, **kwds)        v.__class__ = v  # \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043e \u0431\u044b\u043b\u043e \u043f\u0438\u0441\u0430\u0442\u044c type(sentinel) is sentinel        return v    def __repr__(self):        return self.__name__class IDLE(Sentinel, metaclass=Sentinel):    pass\u042d\u0442\u043e \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 (sentinel-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439), \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 CLIENT, SERVER, IDLE, DONE, NEED_DATA, PAUSED \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.mypyc \u0441\u043f\u043e\u0442\u044b\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u044b:h11\/_util.py:112: error: Inheriting from most builtin types is unimplementednote: Potential workaround: @mypy_extensions.mypyc_attr(native_class=False)\u041f\u0440\u0438\u043a\u043e\u043b \u0441 v.__class__ = v, \u0434\u0430\u044e\u0449\u0438\u0439 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0435\u043d\u0442\u0438\u043d\u0435\u043b\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0432\u0440\u043e\u0434\u0435 type(IDLE) is IDLE, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u043c \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:\u041f\u043e \u0441\u043e\u0432\u0435\u0442\u0443 \u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043e\u0442 mypyc \u043d\u0430\u0432\u0435\u0441\u0438\u0442\u044c @mypyc_attr(native_class=False) \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0436\u0438\u0442\u044c. \u042d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u00ab\u043d\u0435 \u043f\u044b\u0442\u0430\u0439\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 C-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u044c \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 Python-\u043a\u043b\u0430\u0441\u0441\u00bb. \u0418\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432: \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f runtime \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 mypy_extensions, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0431\u0435\u043d\u0435\u0444\u0438\u0442\u043e\u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c Sentinel \u0432 \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e class IDLE(Sentinel), \u0437\u0430\u0431\u0438\u0432 \u043d\u0430 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 __repr__ \u0438 type(sentinel) is sentinel. \u0414\u0443\u043c\u0430\u044e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438, \u044d\u0442\u043e \u043f\u0440\u0438\u0435\u043c\u043b\u0438\u043c\u043e (\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 MR \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0442\u043e \u0442\u0443\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0430\u0434\u043e).\u041f\u043e\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 + \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0441 __repr__ = \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043f\u043e\u0447\u0438\u043d\u0438\u043b\u0438. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u0436\u0435 mypyc \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u0432\u0430\u043c \u043a\u043e\u0434, \u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f .so \u0444\u0430\u0439\u043b\u044b. \u0417\u043d\u0430\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a? \u0416\u0430\u043b\u044c, \u043d\u043e \u043f\u043e\u043a\u0430 \u043d\u0435\u0442\u2026Event(ABC) + \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e slots \u043d\u0430 dataclasses\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u0442\u043e \u0432\u044b\u043b\u0435\u0437\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:import h11print(h11.Event)&gt; uv run python -m test_scriptTraceback (most recent call last):  File &#171;&lt;frozen runpy&gt;&#187;, line 198, in _run_module_as_main  File &#171;&lt;frozen runpy&gt;&#187;, line 88, in _run_code  File &#171;\/home\/danfimov\/Documents\/projects\/h11-mypyc\/a.py&#187;, line 1, in &lt;module&gt;    import h11  File &#171;h11\/__init__.py&#187;, line 9, in &lt;module&gt;    from h11._connection import Connection, NEED_DATA, PAUSED  File &#171;h11\/_connection.py&#187;, line 16, in &lt;module&gt;    from ._events import (  File &#171;h11\/_events.py&#187;, line 41, in &lt;module&gt;    class Request(Event):AttributeError: type object &#8216;Request&#8217; has no attribute &#8216;__slots__&#8217;\u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0434\u0432\u0443\u0445 \u0432\u0435\u0449\u0435\u0439: Event \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 abc.ABC, Request\/Response\/\u2026 \u2014 \u0437\u0430\u043c\u043e\u0440\u043e\u0436\u0435\u043d\u043d\u044b\u0435 @dataclass(init=False, frozen=True) \u0441 \u0440\u0443\u0447\u043d\u044b\u043c __slots__ = (&#8230;) \u0432 \u0442\u0435\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c Python \u044d\u0442\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 mypyc \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u043a\u0430\u043a \u201c\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435\u201d (\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f C, PyTypeObject), \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u043e\u0442\u044b \u0443\u0436\u0435 \u0437\u0430\u0448\u0438\u0442\u044b \u0432 layout \u2014 \u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0441 ABC-\u043c\u0435\u0442\u0430\u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u0430\u0451\u0442 AttributeError \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f.\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c Event \u043e\u0442 ABC \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0442\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e:# \u0431\u044b\u043b\u043eclass Event(ABC):    __slots__ = ()@dataclass(init=False, frozen=True)class Request(Event):    __slots__ = (&#171;method&#187;, &#171;headers&#187;, &#171;target&#187;, &#171;http_version&#187;)    &#8230;# \u0441\u0442\u0430\u043b\u043eclass Event:    pass@dataclass(init=False, frozen=True, slots=True)class Request(Event):    &#8230;\u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u0437 Request\/Response \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 super().__init__(), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u043c\u0430\u0435\u0442 \u0434\u0430\u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 python \u043a\u043e\u0434.\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430:Traceback (most recent call last):  File &#171;&lt;frozen runpy&gt;&#187;, line 198, in _run_module_as_main  File &#171;&lt;frozen runpy&gt;&#187;, line 88, in _run_code  File &#171;\/home\/danfimov\/Documents\/projects\/h11-mypyc\/a.py&#187;, line 1, in &lt;module&gt;    import h11  File &#171;h11\/__init__.py&#187;, line 9, in &lt;module&gt;    from h11._connection import Connection, NEED_DATA, PAUSED  File &#171;h11\/_connection.py&#187;, line 26, in &lt;module&gt;    from ._readers import READERS, ReadersType  File &#171;h11\/_readers.py&#187;, line 25, in &lt;module&gt;    from ._state import (  File &#171;h11\/_state.py&#187;, line 115, in &lt;module&gt;    from ._events import *ModuleNotFoundError: No &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-495452","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/495452","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=495452"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/495452\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=495452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=495452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=495452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}