{"id":366127,"date":"2024-05-21T02:52:47","date_gmt":"2024-05-21T02:52:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=366127"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:52:47","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=366127","title":{"rendered":"<span>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 dict()\u00a0\u0438 {} \u0432 Python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9f4\/329\/933\/9f43299335f0e69afcf47cb08d16d627.png\" width=\"1026\" height=\"470\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f4\/329\/933\/9f43299335f0e69afcf47cb08d16d627.png\"\/><\/figure>\n<p>\u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u043a\u043e\u0434\u0430, \u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u0432\u044b\u0431\u043e\u0440 <code>dict()<\/code>\u00a0\u0432\u043c\u0435\u0441\u0442\u043e <code>{}<\/code>\u00a0\u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435 \u043d\u0430 Python. \u041a\u043e\u043b\u043b\u0435\u0433\u0430 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u043b, \u0447\u0442\u043e <code>dict()<\/code>\u00a0\u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u0447\u0451\u0442\u0447\u0435 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c \u0435\u0433\u043e. \u041c\u0435\u043d\u044f \u044d\u0442\u043e \u043d\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u043e, \u043d\u043e \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0432\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f.<\/p>\n<p>\u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f: \u0432 \u0447\u0451\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u043e\u043c <code>dict<\/code>\u00a0\u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c <code>{}<\/code>?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0412\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043a\u043e\u0434\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.python.org\/downloads\/release\/python-3120\/\" rel=\"noopener noreferrer nofollow\"><u>Python 3.12<\/u><\/a>. \u042d\u0442\u043e <strong>\u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 Python \u0435\u0441\u0442\u044c <a href=\"https:\/\/docs.python.org\/3.12\/whatsnew\/changelog.html\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f<\/u><\/a>  <\/p>\n<\/blockquote>\n<h3>\u0421\u043b\u043e\u0432\u0430\u0440\u0438 Python<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044d\u0442\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>timeit<\/code>.<\/p>\n<pre><code class=\"powershell\">$ python -m timeit \"dict()\" 10000000 loops, best of 5: 40 nsec per loop $ python -m timeit \"{}\" 20000000 loops, best of 5: 19.6 nsec per loop<\/code><\/pre>\n<p>\u041d\u0430 \u043c\u043e\u0451\u043c MacBook M1 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 <strong>\u043f\u043e\u0447\u0442\u0438 \u0434\u0432\u0443\u043a\u0440\u0430\u0442\u043d\u0430\u044f<\/strong>. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435?<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0435\u043c\u044b \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 Python. Python \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Scripting_language\" rel=\"noopener noreferrer nofollow\"><u>\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u043c\u044b\u0439 \u044f\u0437\u044b\u043a<\/u><\/a>, \u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440. \u0421\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0434\u043b\u044f Python \u2014 \u044d\u0442\u043e\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/tree\/v3.12.0\" rel=\"noopener noreferrer nofollow\"><u>CPython<\/u><\/a>; \u044d\u0442\u043e \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0435\u0451 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u00ab\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e\u00bb \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0438 Python \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430, \u0442\u043e \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d CPython.<\/p>\n<p>\u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0447\u0442\u043e CPython \u2014 \u044d\u0442\u043e \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 Python \u043e\u043d \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html#python-bytecode-instructions\" rel=\"noopener noreferrer nofollow\"><u>\u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430<\/u><\/a>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u0445.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 <code>dict()<\/code>\u00a0\u0438 <code>{}<\/code>, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0423 Python \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html\" rel=\"noopener noreferrer nofollow\"><u>dis<\/u><\/a>, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<pre><code class=\"powershell\">>>> import dis >>> def a(): ...   return dict() ... >>> def b(): ...   return {} ... >>> dis.dis(a)   1           0 RESUME                   0    2           2 LOAD_GLOBAL              1 (NULL + dict)              12 CALL                     0              20 RETURN_VALUE >>> dis.dis(b)   1           0 RESUME                   0    2           2 BUILD_MAP                0               4 RETURN_VALUE<\/code><\/pre>\n<p>\u0425\u043e\u0442\u044f \u043e\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h4>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430<\/h4>\n<p>\u0412\u044b\u0432\u043e\u0434 <code>dis.dis<\/code>\u00a0\u043f\u043e\u043d\u044f\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<pre><code> (1) |    (2)    |          (3)          | (4) |      (5)       -----|-----------|-----------------------|-----|---------------    1 |         0 | RESUME                | 0   |      |           |                       |     |    2 |         2 | LOAD_GLOBAL           | 1   | (NULL + dict)      |        12 | CALL                  | 0   |      |        20 | RETURN_VALUE          |     |<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0451 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0410\u0434\u0440\u0435\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u2014 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 (\u043e\u043f\u043a\u043e\u0434).<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u044d\u0442\u0438\u043c \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0441\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043f\u043e <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html#python-bytecode-instructions\" rel=\"noopener noreferrer nofollow\"><u>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u043e\u043f\u043a\u043e\u0434\u043e\u0432<\/u><\/a>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e:<\/p>\n<ol>\n<li>\n<p><code>RESUME<\/code>\u00a0\u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442. \u041e\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435, \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><code>LOAD_GLOBAL<\/code>\u00a0\u2014 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u0442\u0435\u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0418\u0437 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u043f\u043a\u043e\u0434\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 <code>dict<\/code>\u00a0(\u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <code>NULL<\/code>).<\/p>\n<\/li>\n<li>\n<p><code>CALL<\/code>\u00a0\u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u043c <code>argc<\/code>; \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043d\u043e\u043b\u044c.<\/p>\n<\/li>\n<li>\n<p><code>RETURN_VALUE<\/code>\u00a0\u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 <code>return {}<\/code>\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043e\u043f\u043a\u043e\u0434:<\/p>\n<ol start=\"5\">\n<li>\n<p><code>BUILD_MAP<\/code>\u00a0\u2014 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u0442\u0435\u043a \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044f. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 <code>2 * count<\/code>\u00a0\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b <code>count<\/code> \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u043c\u0438. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <code>{}<\/code>\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 <code>dict()<\/code>\u00a0\u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443. \u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u043e\u043d \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u0442\u0435\u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (<code>dict<\/code>); \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0<code>dict<\/code>\u00a0\u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0435\u043d: \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0430 \u043f\u043e\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"powershell\">>>> def a(): ...   return dict() ... >>> dict = lambda: 42 >>> >>> assert a() == 42<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 Python \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u0437\u043b\u0438\u0448\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432\u044b\u0437\u043e\u0432\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041d\u0443 \u043b\u0430\u0434\u043d\u043e, \u0432\u0441\u0451 \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u043e. \u0412\u044b\u0437\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u044e\u044e \u0442\u0440\u0430\u0442\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0438 \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u043e\u0439 \u0442\u0440\u0430\u0442\u044b. \u041d\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u043b\u0438 \u043c\u044b, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 <code>dict()<\/code>\u00a0\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e \u0438 <code>{}<\/code>?\u00a0<code>dict<\/code>\u00a0\u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0438, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>dis.dis<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<pre><code class=\"python\">import dis  class Foo:     def bar(self):         return 42      def __str__(self):         return self.__class__.__name__  dis.dis(Foo)<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<pre><code class=\"powershell\">Disassembly of __str__:   8           0 RESUME                   0    9           2 LOAD_FAST                0 (self)               4 LOAD_ATTR                0 (__class__)              24 LOAD_ATTR                2 (__name__)              44 RETURN_VALUE  Disassembly of bar:   5           0 RESUME                   0    6           2 RETURN_CONST             1 (42)<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0434\u043b\u044f <code>dict<\/code>:<\/p>\n<pre><code class=\"powershell\">>>> dis.dis(dict) >>><\/code><\/pre>\n<p>\u2026 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f? \u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u041d\u0443, \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html\" rel=\"noopener noreferrer nofollow\"><u>dis<\/u><\/a>\u00a0\u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0438 <code>dict<\/code>\u00a0\u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h4>\u0411\u043b\u0443\u0436\u0434\u0430\u0435\u043c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 CPython<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0437\u0430\u043f\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/python\/cpython\/tree\/main\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 CPython<\/u><\/a>. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0432\u0441\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u043a\u0430\u0436\u0435\u043c <code>--depth 1<\/code>.<\/p>\n<pre><code class=\"powershell\">git clone --depth 1 --branch v3.12.0 https:\/\/github.com\/python\/cpython.git # \u0438\u043b\u0438 git clone --depth 1 --branch v3.12.0 git@github.com:python\/cpython.git<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0449\u0435\u043c \u2014 \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u043f\u043a\u043e\u0434\u043e\u0432. \u0412\u044b\u043f\u0438\u0432 \u0447\u0430\u0448\u043a\u0443 \u043a\u043e\u0444\u0435 \u0438 \u0432\u0432\u0435\u0434\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u0430\u043d\u0434 grep, \u043c\u044b, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>Python\/bytecodes.c<\/code>. \u041e\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>switch<\/code>\u00a0\u0438 \u043f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c.<\/p>\n<h4>\u0422\u0438\u043f dict<\/h4>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 <code>dict<\/code>. \u0412\u0441\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0442\u0438\u043f\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b <code>PyTypeObject<\/code>, \u0430 \u0442\u0438\u043f <code>dict<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>dictobject.c<\/code>. \u0423 \u043d\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u043d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430:<\/p>\n<pre><code class=\"cpp\">PyTypeObject PyDict_Type = {     PyVarObject_HEAD_INIT(&amp;PyType_Type, 0)     \"dict\",     sizeof(PyDictObject),     \/\/ ...     dict_init,                                  \/* tp_init *\/     \/\/ ...     dict_new,                                   \/* tp_new *\/     \/\/ ... };<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043f\u0430\u0440\u0430 (<code>dict_new<\/code>\u00a0\u0438 <code>dict_init<\/code>) \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432 Python \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>__new__<\/code>. \u042d\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434-\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>__init__<\/code>. \u041e\u043d \u0431\u0435\u0440\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u041c\u0435\u0442\u043e\u0434 <code>__init__<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>__new__<\/code>.<\/p>\n<\/blockquote>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>dict_new<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0437\u0434\u0435\u0441\u044c:\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/blob\/v3.12.0\/Objects\/dictobject.c#L3751\" rel=\"noopener noreferrer nofollow\"><u>dictobject.c#L3751<\/u><\/a>.<\/p>\n<pre><code class=\"python\">static PyObject * dict_new(PyTypeObject*type, PyObject *args, PyObject*kwds) {     assert(type != NULL);     assert(type->tp_alloc != NULL);     \/\/ dict subclasses must implement the GC protocol     assert(_PyType_IS_GC(type));      PyObject *self = type->tp_alloc(type, 0);     if (self == NULL) {         return NULL;     }     PyDictObject *d = (PyDictObject *)self;      d->ma_used = 0;     d->ma_version_tag = DICT_NEXT_VERSION(             _PyInterpreterState_GET());     dictkeys_incref(Py_EMPTY_KEYS);     d->ma_keys = Py_EMPTY_KEYS;     d->ma_values = NULL;     ASSERT_CONSISTENT(d);      \/\/ ...      return self; }<\/code><\/pre>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (9-\u044f \u0441\u0442\u0440\u043e\u043a\u0430), \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0434\u0430\u0451\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 (15-\u044f, 19-\u044f \u0438 20-\u044f \u0441\u0442\u0440\u043e\u043a\u0438). \u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 <strong>\u043d\u0435<\/strong>\u00a0\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044f (\u0441\u043c. \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438). \u041f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>__new__<\/code>, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0442\u043e\u0434 <code>__init__<\/code>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>dict_init<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dict_update_common<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c:\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/blob\/v3.12.0\/Objects\/dictobject.c#L2678\" rel=\"noopener noreferrer nofollow\"><u>dictobject.c#L2678<\/u><\/a>.<\/p>\n<pre><code class=\"cpp\">static int dict_update_common(PyObject *self, PyObject *args, PyObject *kwds,                    const char *methname) {     PyObject *arg = NULL;     int result = 0;      if (!PyArg_UnpackTuple(args, methname, 0, 1, &amp;arg)) {         result = -1;     }     else if (arg != NULL) {         result = dict_update_arg(self, arg);     }      if (result == 0 &amp;&amp; kwds != NULL) {         if (PyArg_ValidateKeywordArguments(kwds))             result = PyDict_Merge(self, kwds, 1);         else             result = -1;     }     return result; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u0437 args \u0438 kwargs.<\/p>\n<h4>args \u0438 dict_update_arg<\/h4>\n<p>\u0414\u043b\u044f <code>args<\/code>\u00a0\u043e\u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>dict_update_arg<\/code>.<\/p>\n<pre><code class=\"cpp\">static int dict_update_arg(PyObject *self, PyObject *arg) {     if (PyDict_CheckExact(arg)) {         return PyDict_Merge(self, arg, 1);     }     PyObject *func;     if (_PyObject_LookupAttr(arg, &amp;_Py_ID(keys), &amp;func) &lt; 0) {         return -1;     }     if (func != NULL) {         Py_DECREF(func);         return PyDict_Merge(self, arg, 1);     }     return PyDict_MergeFromSeq2(self, arg, 1); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 <code>arg<\/code>\u00a0\u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c, \u0438 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f (<code>PyDict_Merge<\/code>), \u0430 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0430\u0440 (<code>PyDict_MergeFromSeq2<\/code>).<\/p>\n<h4>kwargs \u0438 PyDict_Merge<\/h4>\n<p>\u041f\u0443\u0442\u044c <code>kwargs<\/code>\u00a0\u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u043c\u0435\u0441\u0442\u0435 \u2014\u00a0\u0432 <code>PyDict_Merge<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u044d\u0442\u043e.<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043e\u043d\u0430 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dict_merge<\/code>.<\/p>\n<pre><code class=\"cpp\">static int dict_merge(PyInterpreterState *interp, PyObject *a, PyObject *b, int override) {     PyDictObject *mp, *other;      assert(0 &lt;= override &amp;&amp; override &lt;= 2);      \/* We accept for the argument either a concrete dictionary object,      * or an abstract \"mapping\" object.  For the former, we can do      * things quite efficiently.  For the latter, we only require that      * PyMapping_Keys() and PyObject_GetItem() be supported.      *\/     if (a == NULL || !PyDict_Check(a) || b == NULL) {         PyErr_BadInternalCall();         return -1;     }     mp = (PyDictObject*)a;     if (PyDict_Check(b) &amp;&amp; (Py_TYPE(b)->tp_iter == (getiterfunc)dict_iter)) {          \/\/ ...     else {         \/* Do it the generic, slower way *\/          \/\/ ...     }     ASSERT_CONSISTENT(a);     return 0; }<\/code><\/pre>\n<p>\u0418\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043f\u043e\u0434 \u0432\u044b\u0437\u043e\u0432 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c, \u0442\u043e \u044d\u0442\u043e \u043e\u0431\u0449\u0438\u0439 <code>Mapping<\/code>\u00a0\u2014 \u043e\u0431\u044a\u0435\u043a\u0442-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043a\u043b\u044e\u0447\u0435\u0439.<\/p>\n<h4>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 {}<\/h4>\n<p>\u041b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0449\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u0444\u0430\u0439\u043b\u0443 <a href=\"https:\/\/github.com\/python\/cpython\/blob\/v3.12.0\/Python\/bytecodes.c\" rel=\"noopener noreferrer nofollow\"><u>bytecode.c<\/u><\/a>\u00a0\u0438 \u043d\u0430\u0439\u0434\u0451\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 <code>BUILD_MAP<\/code>.<\/p>\n<pre><code class=\"cpp\">inst(BUILD_MAP, (values[oparg*2] -- map)) {     map = _PyDict_FromItems(             values, 2,             values+1, 2,             oparg);     if (map == NULL)         goto error;      DECREF_INPUTS();     ERROR_IF(map == NULL, error); }<\/code><\/pre>\n<p><em>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0441\u043c. \u0437\u0434\u0435\u0441\u044c:\u00a0<\/em><a href=\"https:\/\/github.com\/python\/cpython\/blob\/v3.12.0\/Python\/bytecodes.c#L1541\" rel=\"noopener noreferrer nofollow\"><em><u>bytecode.c#L1541<\/u><\/em><\/a><em>.<\/em><\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>_PyDict_FromItems<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0435\u0439.<\/p>\n<pre><code class=\"cpp\">PyObject * _PyDict_FromItems(PyObject *const *keys, Py_ssize_t keys_offset,                   PyObject *const *values, Py_ssize_t values_offset,                   Py_ssize_t length) {     bool unicode = true;     PyObject *const *ks = keys;     PyInterpreterState *interp = _PyInterpreterState_GET();      for (Py_ssize_t i = 0; i &lt; length; i++) {         if (!PyUnicode_CheckExact(*ks)) {             unicode = false;             break;         }         ks += keys_offset;     }      PyObject *dict = dict_new_presized(interp, length, unicode);     if (dict == NULL) {         return NULL;     }      ks = keys;     PyObject *const *vs = values;      for (Py_ssize_t i = 0; i &lt; length; i++) {         PyObject *key = *ks;         PyObject *value = *vs;         if (PyDict_SetItem(dict, key, value) &lt; 0) {             Py_DECREF(dict);             return NULL;         }         ks += keys_offset;         vs += values_offset;     }      return dict; }<\/code><\/pre>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 18: \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>dict_new<\/code>, \u043e\u043d\u0430 <strong>\u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442<\/strong>\u00a0\u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u044a\u0451\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u043e\u043d\u0430 \u043e\u0434\u043d\u0443 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u044b \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>\u041f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>dict(a=1, b=2)<\/code>, Python \u0434\u043e\u043b\u0436\u0435\u043d:<\/p>\n<ul>\n<li>\n<p>\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439\u00a0<code>PyObject<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>dict<\/code>\u00a0\u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>__new__<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>__init__<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>PyDict_Merge<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0442\u0430\u043a \u043a\u0430\u043a <code>kwargs<\/code>\u00a0\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>dict<\/code>,\u00a0<code>PyDict_Merge<\/code>\u00a0\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 <code>{}<\/code>\u00a0\u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Python:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 <strong>\u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439<\/strong>\u00a0\u0441\u043b\u043e\u0432\u0430\u0440\u044c,<\/p>\n<\/li>\n<li>\n<p>\u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0432 \u0446\u0438\u043a\u043b\u0435, \u0442\u043e \u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0441\u043e\u0431\u044b\u0439 \u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u0441 <code>dict<\/code>\u00a0\u043d\u0430 <code>{}<\/code>. \u0421\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430:<\/p>\n<h4>tl;dr<\/h4>\n<p><code>{}<\/code>\u00a0\u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c <code>dict<\/code>.<\/p>\n<h3>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u0438 (<em>\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e<\/em>) \u0434\u043b\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u0443\u0436\u0435 \u0438 \u0442\u0430\u043a \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0439, \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0438\u043d\u0443 \u0441\u044e\u0434\u0430 \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0439 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<h4>\u0421\u043f\u0438\u0441\u043a\u0438<\/h4>\n<pre><code class=\"powershell\">$ python -m timeit \"list((1, 2, 'a'))\" 5000000 loops, best of 5: 53.4 nsec per loop $ python -m timeit \"[1, 2, 'a']\" 10000000 loops, best of 5: 29.7 nsec per loop<\/code><\/pre>\n<h4>\u0422\u0438\u043f list<\/h4>\n<p>\u0422\u0438\u043f <code>list<\/code>\u00a0Python \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>listobject.c<\/code>:<\/p>\n<pre><code class=\"cpp\">PyTypeObject PyList_Type = {     \/\/ ...     (initproc)list___init__, \/* tp_init *\/     PyType_GenericAlloc, \/* tp_alloc *\/     PyType_GenericNew, \/* tp_new *\/     \/\/ ... }<\/code><\/pre>\n<p><code>PyType_GenericNew<\/code>\u00a0\u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u2014 \u043e\u043d\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 <code>args<\/code>\u00a0\u0438\u00a0<code>kwargs<\/code>, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 <code>type->typ_alloc<\/code>. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a:\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/blob\/main\/Objects\/typeobject.c#L1768\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/python\/cpython\/blob\/main\/Objects\/typeobject.c#L1768<\/u><\/a><\/p>\n<p><code>PyType_GenericAlloc<\/code>\u00a0\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u0435\u0433\u043e (\u0435\u0441\u043b\u0438 \u0441 \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430) \u043a\u0430\u043a \u00ab\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0439\u00bb.<\/p>\n<p><code>list___init__<\/code>\u00a0\u2014 \u044d\u0442\u043e \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>list___init___impl<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0430\u043c\u0443 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b <code>kwarg<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0435\u0441\u043b\u0438 <code>args<\/code>\u00a0\u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430,<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>args<\/code>\u00a0\u0432 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<\/li>\n<\/ul>\n<p><code>list___init___impl<\/code>\u00a0\u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a (\u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0439) \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c (\u0432\u044b\u0437\u044b\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>list_extend<\/code>).<\/p>\n<h4>\u0412\u043e\u043f\u0440\u043e\u0441<\/h4>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0434\u0432\u0430 \u044d\u0442\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430:<\/p>\n<pre><code class=\"python\">list((1, 2, 3))  _tmp = list() _tmp.extend((1, 2, 3))<\/code><\/pre>\n<p>\u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b \u0432\u043e \u0432\u0441\u0451\u043c (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u043a\u043e\u0434\u043e\u0432) \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 C.<\/p>\n<h4>\u041b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 []<\/h4>\n<p>\u041e\u043f\u043a\u043e\u0434 <code>BUILD_LIST<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>_PyList_FromArraySteal<\/code>\u00a0\u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h4>\n<p>\u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.12 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f _PyList_FromArraySteal. \u0421\u043c. <a href=\"https:\/\/docs.python.org\/3.12\/whatsnew\/changelog.html\" rel=\"noopener noreferrer nofollow\"><u>changelog 3.12<\/u><\/a>\u00a0\u0438 <a href=\"https:\/\/github.com\/python\/cpython\/pull\/100147\" rel=\"noopener noreferrer nofollow\"><u>gh-100146<\/u><\/a>. \u0414\u043e \u0432\u0435\u0440\u0441\u0438\u0438 3.12 \u043e\u043f\u043a\u043e\u0434 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u043b <code>POP()<\/code>\u00a0\u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0438\u0445 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<pre><code class=\"python\">while (--oparg >= 0) {     PyObject *item = POP();     PyList_SET_ITEM(list, oparg, item); }<\/code><\/pre>\n<p>\u0421\u043c. <a href=\"https:\/\/github.com\/python\/cpython\/pull\/100147\/files#diff-729a985b0cb8b431cb291f1edb561bbbfea22e3f8c262451cd83328a0936a342L1447-L1450\" rel=\"noopener noreferrer nofollow\"><u>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 gh-100146 PR<\/u><\/a>.<\/p>\n<p>\u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00a0<code>_PyList_FromArraySteal<\/code>\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a (\u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435\u0442) \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"cpp\">PyObject **dst = list->ob_item; memcpy(dst, src, n * sizeof(PyObject *));<\/code><\/pre>\n<h4>\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430<\/h4>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h4>\n<p>\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u043f\u043e\u043c\u043d\u044e, \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u0441 \u0434\u0432\u0443\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438:\u00a0<code>1<\/code>\u00a0\u0438 <code>2<\/code>.<\/p>\n<pre><code class=\"powershell\">$ python -m timeit \"set((1, 2))\" 5000000 loops, best of 5: 82.6 nsec per loop $ python -m timeit \"{1, 2}\" 5000000 loops, best of 5: 45.5 nsec per loop<\/code><\/pre>\n<h4>\u0422\u0438\u043f set<\/h4>\n<p>\u0422\u0438\u043f <code>set<\/code>\u00a0\u0432 Python \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>setobject.c<\/code>:<\/p>\n<pre><code class=\"cpp\">PyTypeObject PySet_Type = {     \/\/ ...     (initproc)set_init, \/* tp_init *\/     PyType_GenericAlloc, \/* tp_alloc *\/     set_new, \/* tp_new *\/     \/\/ ... }<\/code><\/pre>\n<p><code>set_new<\/code>\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430. \u0412\u043d\u0443\u0442\u0440\u0438 \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>make_new_set<\/code>.<\/p>\n<p><code>set_init<\/code>\u00a0\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b <code>kwarg<\/code>,<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0435\u0441\u043b\u0438 <code>args<\/code>\u00a0\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430,<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>args<\/code>\u00a0\u0432 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442,<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0443\u0436\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d, \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0435\u0433\u043e<\/p>\n<\/li>\n<\/ul>\n<p>\u2026 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>set_update_internal<\/code>\u00a0\u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430.<\/p>\n<h4>\u041b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 {1, 2}<\/h4>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u043f\u043a\u043e\u0434\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (\u043f\u0443\u0441\u0442\u043e\u0435), \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<pre><code class=\"cpp\">inst(BUILD_SET, (values[oparg] -- set)) {     set = PySet_New(NULL);     if (set == NULL)     GOTO_ERROR(error);     int err = 0;     for (int i = 0; i &lt; oparg; i++) {         PyObject *item = values[i];         if (err == 0)             err = PySet_Add(set, item);         Py_DECREF(item);     }     if (err != 0) {         Py_DECREF(set);         ERROR_IF(true, error);     } }<\/code><\/pre>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a:\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/blob\/main\/Python\/bytecodes.c#L1627\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/python\/cpython\/blob\/main\/Python\/bytecodes.c#L1627<\/u><\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442:\u00a0<code>{1, 2, 3}<\/code>. \u041e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">   2 BUILD_SET                0    4 LOAD_CONST               1 (frozenset({1, 2, 3}))    6 SET_UPDATE               1    8 RETURN_VALUE<\/code><\/pre>\n<h4>\u041a\u043e\u0440\u0442\u0435\u0436\u0438<\/h4>\n<p>\u0421 \u043d\u0438\u043c\u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u0430\u044f. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0441 \u0442\u0438\u043f\u043e\u043c <code>tuple<\/code>\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u0441\u043e\u0437\u0434\u0430\u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u043d\u044b\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u043b, \u0447\u0442\u043e, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e, \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0430.<\/p>\n<pre><code class=\"powershell\">>>> import sys >>> sys.version_info sys.version_info(major=3, minor=12, micro=1, releaselevel='final', serial=0) >>> >>> def a(): ...   return tuple((1, 2, [])) >>> >>> def b(): ...   return (1, 2, []) >>> >>> import dis >>> >>> dis.dis(a)   1           0 RESUME                   0    2           2 LOAD_GLOBAL              1 (NULL + tuple)              12 LOAD_CONST               1 (1)              14 LOAD_CONST               2 (2)              16 BUILD_LIST               0              18 BUILD_TUPLE              3              20 CALL                     1              28 RETURN_VALUE >>> dis.dis(b)   1           0 RESUME                   0    2           2 LOAD_CONST               1 (1)               4 LOAD_CONST               2 (2)               6 BUILD_LIST               0               8 BUILD_TUPLE              3              10 RETURN_VALUE<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0435 \u0438\u043c\u0435\u043b\u043e \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430.<\/p>\n<h4>\u0422\u0438\u043f tuple<\/h4>\n<p>\u0422\u0438\u043f <code>tuple<\/code>\u00a0\u0432 Python \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>tupleobject.c<\/code>. \u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438 <code>tp_alloc<\/code>, \u043d\u0438 <code>tp_init<\/code>.<\/p>\n<pre><code class=\"cpp\">PyTypeObject PyTuple_Type = {     \/\/ ...     0, \/* tp_init *\/     0, \/* tp_alloc *\/     tuple_new, \/* tp_new *\/     \/\/ ... }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>tuple_new<\/code>\u00a0\u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0430, \u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/788440\/\"> https:\/\/habr.com\/ru\/articles\/788440\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u043a\u043e\u0434\u0430, \u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u0432\u044b\u0431\u043e\u0440 <code>dict()<\/code>\u00a0\u0432\u043c\u0435\u0441\u0442\u043e <code>{}<\/code>\u00a0\u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435 \u043d\u0430 Python. \u041a\u043e\u043b\u043b\u0435\u0433\u0430 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u043b, \u0447\u0442\u043e <code>dict()<\/code>\u00a0\u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u0447\u0451\u0442\u0447\u0435 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c \u0435\u0433\u043e. \u041c\u0435\u043d\u044f \u044d\u0442\u043e \u043d\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u043e, \u043d\u043e \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0432\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f.<\/p>\n<p>\u042d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f: \u0432 \u0447\u0451\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u043e\u043c <code>dict<\/code>\u00a0\u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c <code>{}<\/code>?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0412\u043e \u0432\u0441\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043a\u043e\u0434\u0430 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.python.org\/downloads\/release\/python-3120\/\" rel=\"noopener noreferrer nofollow\"><u>Python 3.12<\/u><\/a>. \u042d\u0442\u043e <strong>\u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 Python \u0435\u0441\u0442\u044c <a href=\"https:\/\/docs.python.org\/3.12\/whatsnew\/changelog.html\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f<\/u><\/a>  <\/p>\n<\/blockquote>\n<h3>\u0421\u043b\u043e\u0432\u0430\u0440\u0438 Python<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044d\u0442\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u043c <code>timeit<\/code>.<\/p>\n<pre><code class=\"powershell\">$ python -m timeit \"dict()\" 10000000 loops, best of 5: 40 nsec per loop $ python -m timeit \"{}\" 20000000 loops, best of 5: 19.6 nsec per loop<\/code><\/pre>\n<p>\u041d\u0430 \u043c\u043e\u0451\u043c MacBook M1 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 <strong>\u043f\u043e\u0447\u0442\u0438 \u0434\u0432\u0443\u043a\u0440\u0430\u0442\u043d\u0430\u044f<\/strong>. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435?<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u044d\u0442\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u0435\u043c\u044b \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 Python. Python \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Scripting_language\" rel=\"noopener noreferrer nofollow\"><u>\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u043c\u044b\u0439 \u044f\u0437\u044b\u043a<\/u><\/a>, \u0435\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440. \u0421\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0434\u043b\u044f Python \u2014 \u044d\u0442\u043e\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/tree\/v3.12.0\" rel=\"noopener noreferrer nofollow\"><u>CPython<\/u><\/a>; \u044d\u0442\u043e \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0435\u0451 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u00ab\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e\u00bb \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0438 Python \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0430, \u0442\u043e \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d CPython.<\/p>\n<p>\u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0447\u0442\u043e CPython \u2014 \u044d\u0442\u043e \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 Python \u043e\u043d \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html#python-bytecode-instructions\" rel=\"noopener noreferrer nofollow\"><u>\u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430<\/u><\/a>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u0445.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 <code>dict()<\/code>\u00a0\u0438 <code>{}<\/code>, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0423 Python \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html\" rel=\"noopener noreferrer nofollow\"><u>dis<\/u><\/a>, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<pre><code class=\"powershell\">>>> import dis >>> def a(): ...   return dict() ... >>> def b(): ...   return {} ... >>> dis.dis(a)   1           0 RESUME                   0    2           2 LOAD_GLOBAL              1 (NULL + dict)              12 CALL                     0              20 RETURN_VALUE >>> dis.dis(b)   1           0 RESUME                   0    2           2 BUILD_MAP                0               4 RETURN_VALUE<\/code><\/pre>\n<p>\u0425\u043e\u0442\u044f \u043e\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h4>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430<\/h4>\n<p>\u0412\u044b\u0432\u043e\u0434 <code>dis.dis<\/code>\u00a0\u043f\u043e\u043d\u044f\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<pre><code> (1) |    (2)    |          (3)          | (4) |      (5)       -----|-----------|-----------------------|-----|---------------    1 |         0 | RESUME                | 0   |      |           |                       |     |    2 |         2 | LOAD_GLOBAL           | 1   | (NULL + dict)      |        12 | CALL                  | 0   |      |        20 | RETURN_VALUE          |     |<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0451 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0410\u0434\u0440\u0435\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u2014 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 (\u043e\u043f\u043a\u043e\u0434).<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u044d\u0442\u0438\u043c \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0441\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043f\u043e <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html#python-bytecode-instructions\" rel=\"noopener noreferrer nofollow\"><u>\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u043e\u043f\u043a\u043e\u0434\u043e\u0432<\/u><\/a>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e:<\/p>\n<ol>\n<li>\n<p><code>RESUME<\/code>\u00a0\u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442. \u041e\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435, \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><code>LOAD_GLOBAL<\/code>\u00a0\u2014 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u0442\u0435\u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0418\u0437 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u043f\u043a\u043e\u0434\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 <code>dict<\/code>\u00a0(\u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <code>NULL<\/code>).<\/p>\n<\/li>\n<li>\n<p><code>CALL<\/code>\u00a0\u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u043c <code>argc<\/code>; \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043d\u043e\u043b\u044c.<\/p>\n<\/li>\n<li>\n<p><code>RETURN_VALUE<\/code>\u00a0\u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 <code>return {}<\/code>\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043e\u043f\u043a\u043e\u0434:<\/p>\n<ol start=\"5\">\n<li>\n<p><code>BUILD_MAP<\/code>\u00a0\u2014 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u0442\u0435\u043a \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044f. \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 <code>2 * count<\/code>\u00a0\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b <code>count<\/code> \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/p>\n<\/li>\n<\/ol>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u043c\u0438. \u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <code>{}<\/code>\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 <code>dict()<\/code>\u00a0\u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443. \u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u043e\u043d \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u0442\u0435\u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (<code>dict<\/code>); \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0<code>dict<\/code>\u00a0\u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u0435\u043d: \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0430 \u043f\u043e\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"powershell\">>>> def a(): ...   return dict() ... >>> dict = lambda: 42 >>> >>> assert a() == 42<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 Python \u0434\u043e\u043b\u0436\u0435\u043d \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0438\u0437\u043b\u0438\u0448\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432\u044b\u0437\u043e\u0432\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u041d\u0443 \u043b\u0430\u0434\u043d\u043e, \u0432\u0441\u0451 \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u043e. \u0412\u044b\u0437\u043e\u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u044e\u044e \u0442\u0440\u0430\u0442\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0438 \u0440\u0430\u0437\u0443\u043c\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u043e\u0439 \u0442\u0440\u0430\u0442\u044b. \u041d\u043e \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u043b\u0438 \u043c\u044b, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 <code>dict()<\/code>\u00a0\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e \u0438 <code>{}<\/code>?\u00a0<code>dict<\/code>\u00a0\u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0438, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>dis.dis<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<pre><code class=\"python\">import dis  class Foo:     def bar(self):         return 42      def __str__(self):         return self.__class__.__name__  dis.dis(Foo)<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<pre><code class=\"powershell\">Disassembly of __str__:   8           0 RESUME                   0    9           2 LOAD_FAST                0 (self)               4 LOAD_ATTR                0 (__class__)              24 LOAD_ATTR                2 (__name__)              44 RETURN_VALUE  Disassembly of bar:   5           0 RESUME                   0    6           2 RETURN_CONST             1 (42)<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0434\u043b\u044f <code>dict<\/code>:<\/p>\n<pre><code class=\"powershell\">>>> dis.dis(dict) >>><\/code><\/pre>\n<p>\u2026 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f? \u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u041d\u0443, \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.python.org\/3.12\/library\/dis.html\" rel=\"noopener noreferrer nofollow\"><u>dis<\/u><\/a>\u00a0\u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u0438 <code>dict<\/code>\u00a0\u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h4>\u0411\u043b\u0443\u0436\u0434\u0430\u0435\u043c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 CPython<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0437\u0430\u043f\u0440\u0435\u0442\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/python\/cpython\/tree\/main\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 CPython<\/u><\/a>. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0432\u0441\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u043a\u0430\u0436\u0435\u043c <code>--depth 1<\/code>.<\/p>\n<pre><code class=\"powershell\">git clone --depth 1 --branch v3.12.0 https:\/\/github.com\/python\/cpython.git # \u0438\u043b\u0438 git clone --depth 1 --branch v3.12.0 git@github.com:python\/cpython.git<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0449\u0435\u043c \u2014 \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u043f\u043a\u043e\u0434\u043e\u0432. \u0412\u044b\u043f\u0438\u0432 \u0447\u0430\u0448\u043a\u0443 \u043a\u043e\u0444\u0435 \u0438 \u0432\u0432\u0435\u0434\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u0430\u043d\u0434 grep, \u043c\u044b, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>Python\/bytecodes.c<\/code>. \u041e\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>switch<\/code>\u00a0\u0438 \u043f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0442\u0441\u044f \u0437\u0434\u0435\u0441\u044c.<\/p>\n<h4>\u0422\u0438\u043f dict<\/h4>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 <code>dict<\/code>. \u0412\u0441\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0442\u0438\u043f\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b <code>PyTypeObject<\/code>, \u0430 \u0442\u0438\u043f <code>dict<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>dictobject.c<\/code>. \u0423 \u043d\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u043d\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430:<\/p>\n<pre><code class=\"cpp\">PyTypeObject PyDict_Type = {     PyVarObject_HEAD_INIT(&amp;PyType_Type, 0)     \"dict\",     sizeof(PyDictObject),     \/\/ ...     dict_init,                                  \/* tp_init *\/     \/\/ ...     dict_new,                                   \/* tp_new *\/     \/\/ ... };<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043f\u0430\u0440\u0430 (<code>dict_new<\/code>\u00a0\u0438 <code>dict_init<\/code>) \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c.<\/p>\n<blockquote>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432 Python \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>__new__<\/code>. \u042d\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434-\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>__init__<\/code>. \u041e\u043d \u0431\u0435\u0440\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u041c\u0435\u0442\u043e\u0434 <code>__init__<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>__new__<\/code>.<\/p>\n<\/blockquote>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>dict_new<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0437\u0434\u0435\u0441\u044c:\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/blob\/v3.12.0\/Objects\/dictobject.c#L3751\" rel=\"noopener noreferrer nofollow\"><u>dictobject.c#L3751<\/u><\/a>.<\/p>\n<pre><code class=\"python\">static PyObject * dict_new(PyTypeObject*type, PyObject *args, PyObject*kwds) {     assert(type != NULL);     assert(type->tp_alloc != NULL);     \/\/ dict subclasses must implement the GC protocol     assert(_PyType_IS_GC(type));      PyObject *self = type->tp_alloc(type, 0);     if (self == NULL) {         return NULL;     }     PyDictObject *d = (PyDictObject *)self;      d->ma_used = 0;     d->ma_version_tag = DICT_NEXT_VERSION(             _PyInterpreterState_GET());     dictkeys_incref(Py_EMPTY_KEYS);     d->ma_keys = Py_EMPTY_KEYS;     d->ma_values = NULL;     ASSERT_CONSISTENT(d);      \/\/ ...      return self; }<\/code><\/pre>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c (9-\u044f \u0441\u0442\u0440\u043e\u043a\u0430), \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0434\u0430\u0451\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 (15-\u044f, 19-\u044f \u0438 20-\u044f \u0441\u0442\u0440\u043e\u043a\u0438). \u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 <strong>\u043d\u0435<\/strong>\u00a0\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044f (\u0441\u043c. \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438). \u041f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>__new__<\/code>, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0442\u043e\u0434 <code>__init__<\/code>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>dict_init<\/code>\u00a0\u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dict_update_common<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c:\u00a0<a href=\"https:\/\/github.com\/python\/cpython\/blob\/v3.12.0\/Objects\/dictobject.c#L2678\" rel=\"noopener noreferrer nofollow\"><u>dictobject.c#L2678<\/u><\/a>.<\/p>\n<pre><code class=\"cpp\">static int dict_update_common(PyObject *self, PyObject *args, PyObject *kwds,                    const char *methname) {     PyObject *arg = NULL;     int result = 0;      if (!PyArg_UnpackTuple(args, methname, 0, 1, &amp;arg)) {         result = -1;     }     else if (arg != NULL) {         result = dict_update_arg(self, arg);     }      if (result == 0 &amp;&amp; kwds != NULL) {         if (PyArg_ValidateKeywordArguments(kwds))             result = PyDict_Merge(self, kwds, 1);         else             result = -1;     }     return result; }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u0437 args \u0438 kwargs.<\/p>\n<h4>args \u0438 dict_update_arg<\/h4>\n<p>\u0414\u043b\u044f <code>args<\/code>\u00a0\u043e\u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>dict_update_arg<\/code>.<\/p>\n<pre><code class=\"cpp\">static int dict_update_arg(PyObject *self, PyObject *arg) {     if (PyDict_CheckExact(arg)) {         return PyDict_Merge(self, arg, 1);     }     PyObject *func;     if (_PyObject_LookupAttr(arg, &amp;_Py_ID(keys), &amp;func) &lt; 0) {         return -1;     }     if (func != NULL) {         Py_DECREF(func);         return PyDict_Merge(self, arg, 1);     }     return PyDict_MergeFromSeq2(self, arg, 1); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 <code>arg<\/code>\u00a0\u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c, \u0438 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f (<code>PyDict_Merge<\/code>), \u0430 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0430\u0440 (<code>PyDict_MergeFromSeq2<\/code>).<\/p>\n<h4>kwargs \u0438 PyDict_Merge<\/h4>\n<p>\u041f\u0443\u0442\u044c <code>kwargs<\/code>\u00a0\u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u043c\u0435\u0441\u0442\u0435 \u2014\u00a0\u0432 <code>PyDict_Merge<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u044d\u0442\u043e.<\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043e\u043d\u0430 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>dict_merge<\/code>.<\/p>\n<pre><code class=\"cpp\">static int dict_merge(PyInterpreterState *interp, PyObject *a, PyObject *b, int override) {     PyDictObject *mp, *other;      assert(0 &lt;= override &amp;&amp; override &lt;= 2);      \/* We accept for the argument either a concrete dictionary object,      * or an<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-366127","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/366127","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=366127"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/366127\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=366127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=366127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=366127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}