{"id":333418,"date":"2022-05-20T15:00:28","date_gmt":"2022-05-20T15:00:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333418"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333418","title":{"rendered":"<span>\u041e \u0447\u0435\u043c \u0431\u043e\u044f\u0442\u0441\u044f \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c Junior DS. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u044f \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430. \u041c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b \u043e\u043f\u044b\u0442\u043d\u044b\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430\u043c \u0438 \u043e \u043d\u0438\u0445, \u043d\u0435\u0440\u0435\u0434\u043a\u043e, \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435 Data Scientist&#8217;\u044b.<\/p>\n<p><\/p>\n<blockquote>\n<p><strong><em>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440: \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0444\u0435\u0440\u0435, \u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u044b \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b, \u043f\u043e\u043f\u0440\u043e\u0448\u0443 \u043e\u0442\u043d\u0435\u0441\u0442\u0438\u0441\u044c \u0441 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u043c. <\/em><\/strong><\/p>\n<\/blockquote>\n<p><\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0431\u043e\u0439 \u0441\u043d\u0435\u0436\u043d\u044b\u0439 \u043a\u043e\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u043e\u0442 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u0438, \u0431\u043b\u0438\u0436\u0435 \u043a \u043a\u043e\u043d\u0446\u0443, \u043c\u044b \u0434\u043e\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0434\u043e \u0442\u0440\u044e\u043a\u043e\u0432 \u0438 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043e\u043f\u044b\u0442\u043e\u043c. <\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0442\u043e \u044d\u0442\u0430 \u0432\u0430\u0448\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f?<\/h3>\n<p><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5e5\/47c\/30e\/5e547c30ef8a3b9ae2f51aec269dbb94.png\" alt=\"\" title=\"\" width=\"862\" height=\"559\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5e5\/47c\/30e\/5e547c30ef8a3b9ae2f51aec269dbb94.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u044e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0440\u0438\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u041e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f? \u0415\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u043e \u0432\u044b \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443!<\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0435\u043c \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e, \u0432\u0437\u044f\u0442\u043e\u043c\u0443 \u0438\u0437 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9E%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438:<\/a><\/p>\n<blockquote>\n<p><strong><em>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f <\/em><\/strong><em>&#8212; \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043e\u0434\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a, \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439, \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432.<\/em><\/p>\n<\/blockquote>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b<strong> <\/strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c <strong>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/strong>, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f <strong>\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u0442\u0440\u0430\u0442\u044b (\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f)<\/strong> \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <strong>\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438).<\/strong><\/p>\n<p><em>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0438 \u0441\u043e\u0432\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c.<\/em><\/p>\n<hr\/>\n<h3>I. \u0417\u043d\u0430\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041a\u0430\u043a \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0432 Python \u0435\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>\u041a \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c, \u043f\u043e\u043c\u0438\u043c\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (float, int),  \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 (bool) \u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 (str) \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u044b (tuple). \u041a \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0438\u043f\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a (list), \u0441\u043b\u043e\u0432\u0430\u0440\u044c (dict) \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (set). <\/p>\n<p>\u041d\u0435\u0440\u0435\u0434\u043a\u043e, \u0437\u043d\u0430\u043d\u0438\u0435, \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445  \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<blockquote>\n<p><em>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. <\/em><\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0437\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0438\u043c:<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435. \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 O(1), \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438\u0434\u0435\u0442 \u043f\u043e \u0445\u0435\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043a\u043b\u044e\u0447\u0430. \u041b\u0438\u0441\u0442 \u0438\u043c\u0435\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 O(n). <\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442:<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (set). <\/p>\n<blockquote>\n<p><em>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0442.\u0435. \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. <\/em><\/p>\n<\/blockquote>\n<p>\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0443\u043c\u043c\u044b \u0438\u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"python\">a\u00a0=\u00a0[1,2,3,4,5,6,6,1,8,9,3,4,5] b = [0,7,3,4,5,4,2,1,8,9,3,4,5] print(a) print(b)<\/code><\/pre>\n<p>[1, 2, 3, 4, 5, 6, 6, 1, 8, 9, 3, 4, 5]<\/p>\n<p>[0, 7, 3, 4, 5, 4, 2, 1, 8, 9, 3, 4, 5]<\/p>\n<pre><code class=\"python\">c\u00a0=\u00a0set(a) d\u00a0=\u00a0set(b) print(c) print(d) print(f'\u0440\u0430\u0437\u043d\u0438\u0446\u0430\u00a0\u043c\u0435\u0436\u0434\u0443\u00a0c\u00a0\u0438\u00a0d:{c-d}') print(f'\u0440\u0430\u0437\u043d\u0438\u0446\u0430\u00a0\u043c\u0435\u0436\u0434\u0443\u00a0d\u00a0\u0438\u00a0c:{d-c}') print(f'\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u00a0\u00a0c\u00a0\u0438\u00a0d:\u00a0{c.union(d)}')<\/code><\/pre>\n<p>{1, 2, 3, 4, 5, 6, 8, 9}<\/p>\n<p>{0, 1, 2, 3, 4, 5, 7, 8, 9}<\/p>\n<p>\u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 c \u0438 d:{6}<\/p>\n<p>\u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 d \u0438 c:{0, 7}<\/p>\n<p>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435  c \u0438 d: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u0441\u043e\u0432\u0435\u0442\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435. <\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c  \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u043e\u0437\u0436\u0435 \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435:<\/strong><\/p>\n<\/li>\n<\/ul>\n<p><em>\u0417\u0434\u0435\u0441\u044c, \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a \u0438 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0430\u043a \u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435.<\/em> <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ul>\n<li>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043a\u043e\u0440\u0442\u0435\u0436 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 (str), \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0431\u044a\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0432 \u0446\u0438\u043a\u043b\u0435. \u0414\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c magic-\u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>%timeit<\/code>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%timeit\u00a0parameters_list\u00a0=\u00a0['1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th']<\/code><\/pre>\n<p>The slowest run took 15.35 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 74.6 ns per loop<\/p>\n<pre><code class=\"python\">%timeit\u00a0parameters_tuple\u00a0=\u00a0('1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th')<\/code><\/pre>\n<p>The slowest run took 51.93 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 20.5 ns per loop<\/p>\n<blockquote>\n<p><em>\u0412 \u0446\u0435\u043b\u043e\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439!<\/em><\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0442\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 getsizeof \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 sys:<\/p>\n<\/li>\n<\/ul>\n<pre><code>from\u00a0sys\u00a0import\u00a0getsizeof parameters_list\u00a0=\u00a0['1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th'] parameters_tuple\u00a0=\u00a0('1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th') print(f'\u0440\u0430\u0437\u043c\u0435\u0440\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u00a0\u0441\u043f\u0438\u0441\u043a\u0430\u00a0{getsizeof(parameters_list)}\u00a0\u0431\u0438\u0442') print(f'\u0440\u0430\u0437\u043c\u0435\u0440\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u00a0\u043a\u043e\u0440\u0442\u0435\u0436\u0430\u00a0{getsizeof(parameters_tuple)}\u00a0\u0431\u0438\u0442') <\/code><\/pre>\n<p>\u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 112 \u0431\u0438\u0442<\/p>\n<p>\u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 96 \u0431\u0438\u0442<\/p>\n<blockquote>\n<p><em>\u041f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u0436\u0435 \u0432\u0438\u0434\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f!<\/em><\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e \u0434\u0432\u0443\u043c \u0442\u0438\u043f\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%%timeit for\u00a0param\u00a0in\u00a0parameters_list: pass<\/code><\/pre>\n<p>The slowest run took 17.38 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 142 ns per loop<\/p>\n<pre><code class=\"python\">%%timeit for\u00a0param\u00a0in\u00a0parameters_tuple: pass<\/code><\/pre>\n<p>The slowest run took 13.72 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 142 ns per loop<\/p>\n<blockquote>\n<p><em>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u0437\u044f\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u0430\u043a \u0436\u0435 \u0432 \u0441\u0430\u043c\u044b\u0439 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u043a \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u0445!<\/em><\/p>\n<\/blockquote>\n<p><strong><em>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u0446\u0438\u043a\u043b\u043e\u043c, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438.<\/em><\/strong><\/p>\n<hr\/>\n<h3>II. \u0417\u0430\u0431\u0443\u0434\u044c \u043f\u0440\u043e append!<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c <strong><em>\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 append \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043f\u0438\u0441\u043a\u0430<\/em><\/strong>.  \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 (List comprehension). \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435: <\/p>\n<pre><code class=\"python\">%%timeit a\u00a0=\u00a0list() for\u00a0i\u00a0in\u00a0range(100):   a.append(i)<\/code><\/pre>\n<p>100000 loops, best of 5: 7.68 \u00b5s per loop<\/p>\n<pre><code class=\"python\">%timeit\u00a0a\u00a0=\u00a0[i\u00a0for\u00a0i\u00a0in\u00a0range(100)]<\/code><\/pre>\n<p>100000 loops, best of 5: 3.98 \u00b5s per loop<\/p>\n<blockquote>\n<p><em>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e \u0434\u0432\u0443\u0445 \u0440\u0430\u0437!<\/em><\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 (List comprehension) \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 \u0432 \u0446\u0438\u043a\u043b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 0 \u0434\u043e 100:<\/p>\n<ul>\n<li>\n<p>\u0432 \u0446\u0438\u043a\u043b\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%%timeit a\u00a0=\u00a0[] for\u00a0i\u00a0in\u00a0range(102): if\u00a0i%2==0:   a.append(i)<\/code><\/pre>\n<p>100000 loops, best of 5: 9.82 \u00b5s per loop<\/p>\n<ul>\n<li>\n<p>c \u043f\u043e\u043c\u043e\u0449\u044c\u044e List comprehension:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%timeit\u00a0a\u00a0=\u00a0[i\u00a0for\u00a0i\u00a0in\u00a0range(102)\u00a0if\u00a0i%2==0]<\/code><\/pre>\n<p>100000 loops, best of 5: 7.78 \u00b5s per loop<\/p>\n<p><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0444\u0438\u043b\u044c\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435!<\/p>\n<hr\/>\n<h3>III. + \u0432 \u043a\u0430\u0440\u043c\u0443, &#8212; \u043a \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438<\/h3>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c31\/dda\/984\/c31dda9849c2890b0eb4748d0ba66f66.png\" alt=\"I WILL NOT SLEEP THROUGH MY EDUCATION\" title=\"I WILL NOT SLEEP THROUGH MY EDUCATION\" width=\"480\" height=\"366\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c31\/dda\/984\/c31dda9849c2890b0eb4748d0ba66f66.png\"\/><figcaption>I WILL NOT SLEEP THROUGH MY EDUCATION<\/figcaption><\/figure>\n<p><\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f &#171;\u0441\u043a\u043b\u0435\u0438\u0442\u044c&#187; \u0434\u0432\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u043e\u0434\u043d\u0443.<\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043d\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u0447\u0435\u0440\u0435\u0437 \u043f\u043b\u044e\u0441. <\/p>\n<p>\u041e\u0431\u044a\u044f\u0441\u043d\u044e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ol>\n<li>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0438 <code>\"I\", \"WILL\", \"NOT\", \"SLEEP\", \"THROUGH\", \"MY\", \"EDUCATION\"<\/code><\/p>\n<\/li>\n<li>\n<p>\u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u0447\u0435\u043a<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 6 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">input\u00a0=\u00a0['I',\u00a0'WILL',\u00a0'NOT',\u00a0'SLEEP',\u00a0'THROUGH',\u00a0'MY',\u00a0'EDUCATION'] %%timeit\u00a0 out\u00a0=\u00a0'' for word\u00a0in\u00a0input: out\u00a0+=\u00a0word<\/code><\/pre>\n<p>The slowest run took 4.22 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>1000000 loops, best of 5: 557 ns per loop<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 join \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u044c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u0443 6 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445.<\/em><\/p>\n<\/blockquote>\n<pre><code class=\"python\">%timeit\u00a0out\u00a0=\u00a0'\u00a0'.join(input)<\/code><\/pre>\n<p>The slowest run took 18.70 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 181 ns per loop<\/p>\n<p><\/p>\n<p><strong><em>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0435\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 join! <\/em><\/strong><\/p>\n<hr\/>\n<h3>IV. \u0414\u0430\u0436\u0435 \u0438\u043c\u043f\u043e\u0440\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c!<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 math:<\/p>\n<ul>\n<li>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">import\u00a0math\u00a0 %timeit math.log(2022)<\/code><\/pre>\n<p>The slowest run took 46.74 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 150 ns per loop<\/p>\n<pre><code class=\"python\">from\u00a0math\u00a0import\u00a0log %timeit\u00a0log(2022)<\/code><\/pre>\n<p>The slowest run took 49.43 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 123 ns per loop<\/p>\n<p>\u0421\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435!<\/p>\n<blockquote>\n<p><em>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 math.log() \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 __getattribute()__ \u0438\u043b\u0438 __getattr()__, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0449\u0435\u0442 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 math \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439.<\/em><\/p>\n<\/blockquote>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u0435\u043d.<\/p>\n<hr\/>\n<h3>V. \u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0439!<\/h3>\n<p><strong>V.I Numpy<\/strong><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c, \u0447\u0442\u043e \u044f\u0437\u044b\u043a\u0438 C\/C++ \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c Python, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0432 \u0432\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u044f\u0437\u044b\u043a\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0422\u0430\u043a, \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 numpy \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 C++, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0439 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438. <\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">a = [i for i in range(50)] b = np.array([i for i in range(50)])<\/code><\/pre>\n<pre><code class=\"python\">%%timeit for i in range(len(a)): a[i] *= 5<\/code><\/pre>\n<p><em>10000 loops, best of 5: 71.4 \u00b5s per loop<\/em><\/p>\n<pre><code class=\"python\">%timeit c = b*5<\/code><\/pre>\n<p>The slowest run took 37.82 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>1000000 loops, best of 5: 845 ns per loop<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e \u0432\u0441\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0443 \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f <strong>\u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>.<\/p>\n<blockquote>\n<p><em>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0446\u0438\u043a\u043b\u0430 \u0432 numpy. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u044f\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u044b!<\/em><\/p>\n<\/blockquote>\n<p> \u0422\u0430\u043a, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u043d\u0435 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430 \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0443:<\/p>\n<pre><code class=\"python\">from numpy import zeros, float64, cos, arange n = 100000<\/code><\/pre>\n<ul>\n<li>\n<p>\u043d\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%%timeit a = zeros([n], float64) for i in range(n): a[i] = cos(i)<\/code><\/pre>\n<p>10 loops, best of 5: 130 ms per loop<\/p>\n<ul>\n<li>\n<p>\u0442\u043e\u0442 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043d\u043e \u0443\u0436\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%%timeit val = arange(0, n) a = cos(val)<\/code><\/pre>\n<p>100 loops, best of 5: 2.47 ms per loop<\/p>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430!<\/p>\n<p><strong>V.II Pandas<\/strong><\/p>\n<p>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u0430\u043a \u0436\u0435 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 pandas, \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445:<\/p>\n<ul>\n<li>\n<p><code>apply<\/code>, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a DataFrame \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u0438\u043b\u0438 \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0443<\/p>\n<\/li>\n<li>\n<p><code>map<\/code>, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u0441\u0442\u043e\u043b\u0431\u0446\u0443 (Series)<\/p>\n<\/li>\n<li>\n<p><code>applymap<\/code>, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 DataFrame.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c:<\/p>\n<pre><code class=\"python\">col1 = [1, 2, 3, 4] col2 = [5, 6, 7, 8] d = {'one':col1, 'two':col2} df = pd.DataFrame(d)<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0440\u0430\u0441\u0447\u0435\u0442 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c,<\/p>\n<pre><code class=\"python\">df.apply(np.std)<\/code><\/pre>\n<p>one    1.118034<\/p>\n<p>two    1.118034<\/p>\n<p>dtype: float64<\/p>\n<p>\u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043d\u0430\u0448\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<blockquote>\n<p><em>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e &#8212; \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0446\u0438\u043a\u043b\u043e\u0432!<\/em><\/p>\n<\/blockquote>\n<pre><code class=\"python\">df.applymap(lambda x: x2)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/298\/786\/67f\/29878667f37fc9c1cca7f0d2bcb94ba1.png\" alt=\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430\" title=\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430\" width=\"732\" height=\"176\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/298\/786\/67f\/29878667f37fc9c1cca7f0d2bcb94ba1.png\"\/><figcaption>\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430<\/figcaption><\/figure>\n<p><strong>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438:<\/strong><\/p>\n<pre><code class=\"python\">df['one'].map(lambda x: x2)<\/code><\/pre>\n<p>0     1<\/p>\n<p>1     4<\/p>\n<p>2     9<\/p>\n<p>3    16<\/p>\n<p>Name: one, dtype: int64<\/p>\n<p><\/p>\n<blockquote>\n<p><em>\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430!<\/em><\/p>\n<\/blockquote>\n<hr\/>\n<p><\/p>\n<h4>VI. \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f &#8212; \u043c\u0443\u0434\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u0443\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443, \u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e. \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c <strong>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/strong>. \u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/docs.python.org\/3\/library\/multiprocessing.html\" rel=\"noopener noreferrer nofollow\">multiprocessing<\/a>. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430 5 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442:<\/p>\n<pre><code class=\"python\">from multiprocessing import Pool def f(x): return x*x if name == 'main': with Pool(5) as p: print(p.map(f, [1, 2, 3, 4, 5])) <\/code><\/pre>\n<p>\u0432\u044b\u0432\u043e\u0434:<\/p>\n<p>[1, 4, 9, 16, 25]<\/p>\n<p><\/p>\n<h4>VII. \u0421\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h4>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. <\/p>\n<p><strong>VII.I Modin<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1e6\/6ef\/178\/1e66ef1783646db765b1c2f1c5d25466.png\" alt=\"\" title=\"\" width=\"710\" height=\"140\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1e6\/6ef\/178\/1e66ef1783646db765b1c2f1c5d25466.png\"\/><figcaption><\/figcaption><\/figure>\n<p><\/p>\n<p>\u041d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043e\u0431\u0435\u0440\u0442\u043e\u043a, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <a href=\"https:\/\/modin.readthedocs.io\/en\/stable\/\" rel=\"noopener noreferrer nofollow\">Modin<\/a>. \u0414\u0430\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 pandas \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u044f \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0438\u043c\u043f\u043e\u0440\u0442\u0430:<\/p>\n<p>\u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0430<\/p>\n<pre><code class=\"python\">import pandas as pd<\/code><\/pre>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Modin<\/p>\n<pre><code class=\"python\">import modin.pandas as pd<\/code><\/pre>\n<p>\u041a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b pandas. <\/p>\n<p>\u0422\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0437\u0430\u044f\u0432\u043b\u044f\u044e\u0442, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c 4-\u0445 \u044f\u0434\u0435\u0440\u043d\u043e\u043c \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0435 \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>csv<\/code> \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 700 Mb \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>read_csv<\/code> \u0432 4 \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p><\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e Modin, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445, \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0449\u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0443, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <a href=\"https:\/\/cython.org\/\" rel=\"noopener noreferrer nofollow\">cython <\/a>\u0438 <a href=\"https:\/\/numba.pydata.org\/\" rel=\"noopener noreferrer nofollow\">numba<\/a>. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u043d\u0430 C\/\u0421++ \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 python!<\/p>\n<p>\u0412 cython \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0434-\u0441\u0443\u043f\u0435\u0440\u043f\u043e\u0437\u0438\u0446\u0438\u044f C\/C++ \u0438 python, \u0430 \u0432 numba \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043a\u043e\u0434\u0430, \u0440\u0430\u0437\u0433\u043e\u043d\u044f\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <\/p>\n<p> <strong>VII.II Numba<\/strong><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/432\/bd7\/9bc\/432bd79bca4d03e9ab559794c07bbdfe.png\" alt=\"\" title=\"\" width=\"434\" height=\"116\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/432\/bd7\/9bc\/432bd79bca4d03e9ab559794c07bbdfe.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0440\u044e\u043a \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0441 numba \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0433\u043e\u043d\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/LLVM\" rel=\"noopener noreferrer nofollow\">llvm<\/a>. \u0420\u0430\u0437\u0433\u043e\u043d \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <code>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0438 \u043a\u043e\u0434 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b: \u0410\u043d\u0434\u0440\u0435\u0439 \u0414\u0437\u0438\u0441\u044c, \u043a\u0430\u043d\u0430\u043b \u0432 \u0422\u0413 <span>@dzis_science<\/span>.<span>@jit<\/span>(nopython=True)<span>@jit<\/span><\/code> \u043f\u0435\u0440\u0435\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u043a\u043b\u0430\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0438\u0442\u043e\u043d\u0430 \u0440\u0430\u0437\u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f numba, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u0438\u0442\u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e <a href=\"https:\/\/numba.pydata.org\/numba-doc\/dev\/reference\/pysupported.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>. \u0422\u0430\u043a \u0436\u0435 numba \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 numpy, \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e <a href=\"https:\/\/numba.pydata.org\/numba-doc\/dev\/reference\/numpysupported.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>\u0422.\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 \u0441\u0442\u0440\u043e\u0447\u0435\u043a:<\/p>\n<pre><code class=\"python\">from numda import jit @jit(nopython=True) #\u0432\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/code><\/pre>\n<blockquote>\n<p><em>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 nopython \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c python \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c! \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 nopython \u0440\u0435\u0436\u0438\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u0442 \u0432 object \u0440\u0435\u0436\u0438\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043a\u0443\u0441\u043a\u0430\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0447\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 python.<\/em><\/p>\n<\/blockquote>\n<p><\/p>\n<p> <strong>VII.III Cython<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e66\/c27\/b7f\/e66c27b7f9f69ee3b8e18fd34783090a.png\" alt=\"\" title=\"\" width=\"1200\" height=\"535\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e66\/c27\/b7f\/e66c27b7f9f69ee3b8e18fd34783090a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0442\u0430\u0432\u043a\u0438 \u043a\u043e\u0434\u0430 cython \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u043c\u0435\u0441\u044c python \u0438 \u0421++.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ul>\n<li>\n<p>\u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438  \u043d\u0430 python:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">def sum(x):   out = 0   for i in range(x):     out += i   return out<\/code><\/pre>\n<ul>\n<li>\n<p>\u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u043d\u043e \u0443\u0436\u0435 \u043d\u0430 cython:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">cpdef sum(x):   cdef int out = 0   cdef int i   for i in range(x):   out += i   return out<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c \u0438\u0437 C \u0438 \u0438\u0437 python \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043b\u0430\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 <code>def<\/code>  \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <code>cpdef<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0441\u0442\u0440\u043e\u0433\u0430\u044f (\u043f\u0440\u044f\u043c\u043e \u043a\u0430\u043a \u0432 C) \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>cdef<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0438\u0438 cython \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434 C. \u0422\u0443\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u0444\u0430\u0439\u043b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>.pyx<\/code> \u0438  \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 cythonize \u0438\u0437  <code>Cython.Build<\/code> \u0438 \u043c\u0435\u0442\u043e\u0434\u0430 setup \u0438\u0437 <code>distutils.core<\/code> \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0430\u0439\u043b <code>setup.py<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0434\u0430\u043b\u0435\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0448\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p><\/p>\n<pre><code class=\"python\">from distutils.core import setup from Cython.Build import cythonize setup(ext_modules = cythonize('your_function_name.pyx')) #\u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c python setup.py build_ext --inplace<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u043c \u0441\u043c\u0435\u043b\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\">import your_function_name<\/code><\/pre>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0438\u0441\u044c \u043e\u0431\u043e\u0437\u0440\u0435\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430, \u043e\u0442 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445, \u0434\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0445 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b DS.<\/p>\n<p> \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0431\u044b\u043b \u043f\u043e\u043b\u0435\u0437\u0435\u043d.  <\/p>\n<p>Work! Optimize!<\/p>\n<p><\/p>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0438 \u043a\u043e\u0434 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b: \u0410\u043d\u0434\u0440\u0435\u0439 \u0414\u0437\u0438\u0441\u044c, \u043a\u0430\u043d\u0430\u043b \u0432 \u0422\u0413 <span>@dzis_science<\/span>.<\/p>\n<p><\/p>\n<hr\/>\n<p><strong><em>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0437\u0430\u0449\u0438\u0449\u0435\u043d \u0430\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438.\u00a0<\/em><\/strong><\/p>\n<p><\/p>\n<p><strong><em>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0430, \u0441 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0435\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430.<\/em><\/strong><\/p>\n<p><\/p>\n<p><\/p>\n<p><\/p>\n<p><\/p>\n<p><\/p>\n<p><\/p>\n<p><\/p>\n<p><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/666900\/\"> https:\/\/habr.com\/ru\/post\/666900\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u044f \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430. \u041c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b \u043e\u043f\u044b\u0442\u043d\u044b\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430\u043c \u0438 \u043e \u043d\u0438\u0445, \u043d\u0435\u0440\u0435\u0434\u043a\u043e, \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435 Data Scientist&#8217;\u044b.<\/p>\n<p><\/p>\n<blockquote>\n<p><strong><em>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440: \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0444\u0435\u0440\u0435, \u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u044b \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b, \u043f\u043e\u043f\u0440\u043e\u0448\u0443 \u043e\u0442\u043d\u0435\u0441\u0442\u0438\u0441\u044c \u0441 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u043c. <\/em><\/strong><\/p>\n<\/blockquote>\n<p><\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0431\u043e\u0439 \u0441\u043d\u0435\u0436\u043d\u044b\u0439 \u043a\u043e\u043c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u043e\u0442 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u0438, \u0431\u043b\u0438\u0436\u0435 \u043a \u043a\u043e\u043d\u0446\u0443, \u043c\u044b \u0434\u043e\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0434\u043e \u0442\u0440\u044e\u043a\u043e\u0432 \u0438 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 \u043e\u043f\u044b\u0442\u043e\u043c. <\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u0434\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0442\u043e \u044d\u0442\u0430 \u0432\u0430\u0448\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f?<\/h3>\n<p><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u044e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0440\u0438\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0431\u041e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f? \u0415\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u043e \u0432\u044b \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443!<\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0435\u043c \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e, \u0432\u0437\u044f\u0442\u043e\u043c\u0443 \u0438\u0437 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9E%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F\" rel=\"noopener noreferrer nofollow\">\u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438:<\/a><\/p>\n<blockquote>\n<p><strong><em>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f <\/em><\/strong><em>&#8212; \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043e\u0434\u043d\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a, \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439, \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432.<\/em><\/p>\n<\/blockquote>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b<strong> <\/strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c <strong>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/strong>, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f <strong>\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u0442\u0440\u0430\u0442\u044b (\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f)<\/strong> \u0438 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <strong>\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 (\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438).<\/strong><\/p>\n<p><em>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0438 \u0441\u043e\u0432\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c.<\/em><\/p>\n<hr\/>\n<h3>I. \u0417\u043d\u0430\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041a\u0430\u043a \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0432 Python \u0435\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>\u041a \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c, \u043f\u043e\u043c\u0438\u043c\u043e \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (float, int),  \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 (bool) \u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 (str) \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u044b (tuple). \u041a \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0438\u043f\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a (list), \u0441\u043b\u043e\u0432\u0430\u0440\u044c (dict) \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e (set). <\/p>\n<p>\u041d\u0435\u0440\u0435\u0434\u043a\u043e, \u0437\u043d\u0430\u043d\u0438\u0435, \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445  \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<blockquote>\n<p><em>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. <\/em><\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0437\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0438\u043c:<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435. \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044f, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 O(1), \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438\u0434\u0435\u0442 \u043f\u043e \u0445\u0435\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043a\u043b\u044e\u0447\u0430. \u041b\u0438\u0441\u0442 \u0438\u043c\u0435\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 O(n). <\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442:<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (set). <\/p>\n<blockquote>\n<p><em>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0442.\u0435. \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. <\/em><\/p>\n<\/blockquote>\n<p>\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0443\u043c\u043c\u044b \u0438\u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"python\">a\u00a0=\u00a0[1,2,3,4,5,6,6,1,8,9,3,4,5] b = [0,7,3,4,5,4,2,1,8,9,3,4,5] print(a) print(b)<\/code><\/pre>\n<p>[1, 2, 3, 4, 5, 6, 6, 1, 8, 9, 3, 4, 5]<\/p>\n<p>[0, 7, 3, 4, 5, 4, 2, 1, 8, 9, 3, 4, 5]<\/p>\n<pre><code class=\"python\">c\u00a0=\u00a0set(a) d\u00a0=\u00a0set(b) print(c) print(d) print(f'\u0440\u0430\u0437\u043d\u0438\u0446\u0430\u00a0\u043c\u0435\u0436\u0434\u0443\u00a0c\u00a0\u0438\u00a0d:{c-d}') print(f'\u0440\u0430\u0437\u043d\u0438\u0446\u0430\u00a0\u043c\u0435\u0436\u0434\u0443\u00a0d\u00a0\u0438\u00a0c:{d-c}') print(f'\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u00a0\u00a0c\u00a0\u0438\u00a0d:\u00a0{c.union(d)}')<\/code><\/pre>\n<p>{1, 2, 3, 4, 5, 6, 8, 9}<\/p>\n<p>{0, 1, 2, 3, 4, 5, 7, 8, 9}<\/p>\n<p>\u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 c \u0438 d:{6}<\/p>\n<p>\u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 d \u0438 c:{0, 7}<\/p>\n<p>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435  c \u0438 d: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u0441\u043e\u0432\u0435\u0442\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435. <\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c  \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u043e\u0437\u0436\u0435 \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435:<\/strong><\/p>\n<\/li>\n<\/ul>\n<p><em>\u0417\u0434\u0435\u0441\u044c, \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a \u0438 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0430\u043a \u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435.<\/em> <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ul>\n<li>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043a\u043e\u0440\u0442\u0435\u0436 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0442\u0438\u043f\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 (str), \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0431\u044a\u0435\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0432 \u0446\u0438\u043a\u043b\u0435. \u0414\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c magic-\u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>%timeit<\/code>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%timeit\u00a0parameters_list\u00a0=\u00a0['1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th']<\/code><\/pre>\n<p>The slowest run took 15.35 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 74.6 ns per loop<\/p>\n<pre><code class=\"python\">%timeit\u00a0parameters_tuple\u00a0=\u00a0('1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th')<\/code><\/pre>\n<p>The slowest run took 51.93 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 20.5 ns per loop<\/p>\n<blockquote>\n<p><em>\u0412 \u0446\u0435\u043b\u043e\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439!<\/em><\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0442\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 getsizeof \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 sys:<\/p>\n<\/li>\n<\/ul>\n<pre><code>from\u00a0sys\u00a0import\u00a0getsizeof parameters_list\u00a0=\u00a0['1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th'] parameters_tuple\u00a0=\u00a0('1st',\u00a0'2nd',\u00a0'3rd',\u00a0'4th',\u00a0'5th') print(f'\u0440\u0430\u0437\u043c\u0435\u0440\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u00a0\u0441\u043f\u0438\u0441\u043a\u0430\u00a0{getsizeof(parameters_list)}\u00a0\u0431\u0438\u0442') print(f'\u0440\u0430\u0437\u043c\u0435\u0440\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u00a0\u043a\u043e\u0440\u0442\u0435\u0436\u0430\u00a0{getsizeof(parameters_tuple)}\u00a0\u0431\u0438\u0442') <\/code><\/pre>\n<p>\u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 112 \u0431\u0438\u0442<\/p>\n<p>\u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 96 \u0431\u0438\u0442<\/p>\n<blockquote>\n<p><em>\u041f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u0436\u0435 \u0432\u0438\u0434\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f!<\/em><\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e \u0434\u0432\u0443\u043c \u0442\u0438\u043f\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%%timeit for\u00a0param\u00a0in\u00a0parameters_list: pass<\/code><\/pre>\n<p>The slowest run took 17.38 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 142 ns per loop<\/p>\n<pre><code class=\"python\">%%timeit for\u00a0param\u00a0in\u00a0parameters_tuple: pass<\/code><\/pre>\n<p>The slowest run took 13.72 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 142 ns per loop<\/p>\n<blockquote>\n<p><em>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u0437\u044f\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u0430\u043a \u0436\u0435 \u0432 \u0441\u0430\u043c\u044b\u0439 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u043a \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u0445!<\/em><\/p>\n<\/blockquote>\n<p><strong><em>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u0446\u0438\u043a\u043b\u043e\u043c, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438.<\/em><\/strong><\/p>\n<hr\/>\n<h3>II. \u0417\u0430\u0431\u0443\u0434\u044c \u043f\u0440\u043e append!<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c <strong><em>\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 append \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043f\u0438\u0441\u043a\u0430<\/em><\/strong>.  \u042d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u0430\u043c\u044f\u0442\u0438, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 (List comprehension). \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435: <\/p>\n<pre><code class=\"python\">%%timeit a\u00a0=\u00a0list() for\u00a0i\u00a0in\u00a0range(100):   a.append(i)<\/code><\/pre>\n<p>100000 loops, best of 5: 7.68 \u00b5s per loop<\/p>\n<pre><code class=\"python\">%timeit\u00a0a\u00a0=\u00a0[i\u00a0for\u00a0i\u00a0in\u00a0range(100)]<\/code><\/pre>\n<p>100000 loops, best of 5: 3.98 \u00b5s per loop<\/p>\n<blockquote>\n<p><em>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e \u0434\u0432\u0443\u0445 \u0440\u0430\u0437!<\/em><\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 (List comprehension) \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 \u0432 \u0446\u0438\u043a\u043b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 0 \u0434\u043e 100:<\/p>\n<ul>\n<li>\n<p>\u0432 \u0446\u0438\u043a\u043b\u0435:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%%timeit a\u00a0=\u00a0[] for\u00a0i\u00a0in\u00a0range(102): if\u00a0i%2==0:   a.append(i)<\/code><\/pre>\n<p>100000 loops, best of 5: 9.82 \u00b5s per loop<\/p>\n<ul>\n<li>\n<p>c \u043f\u043e\u043c\u043e\u0449\u044c\u044e List comprehension:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">%timeit\u00a0a\u00a0=\u00a0[i\u00a0for\u00a0i\u00a0in\u00a0range(102)\u00a0if\u00a0i%2==0]<\/code><\/pre>\n<p>100000 loops, best of 5: 7.78 \u00b5s per loop<\/p>\n<p><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0444\u0438\u043b\u044c\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435!<\/p>\n<hr\/>\n<h3>III. + \u0432 \u043a\u0430\u0440\u043c\u0443, &#8212; \u043a \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438<\/h3>\n<figure class=\"\"><figcaption>I WILL NOT SLEEP THROUGH MY EDUCATION<\/figcaption><\/figure>\n<p><\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f &#171;\u0441\u043a\u043b\u0435\u0438\u0442\u044c&#187; \u0434\u0432\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u043e\u0434\u043d\u0443.<\/p>\n<p>\u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043d\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u0447\u0435\u0440\u0435\u0437 \u043f\u043b\u044e\u0441. <\/p>\n<p>\u041e\u0431\u044a\u044f\u0441\u043d\u044e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<ol>\n<li>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0438 <code>\"I\", \"WILL\", \"NOT\", \"SLEEP\", \"THROUGH\", \"MY\", \"EDUCATION\"<\/code><\/p>\n<\/li>\n<li>\n<p>\u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u0430\u043a \u0441\u0443\u043c\u043c\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u0447\u0435\u043a<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c 6 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">input\u00a0=\u00a0['I',\u00a0'WILL',\u00a0'NOT',\u00a0'SLEEP',\u00a0'THROUGH',\u00a0'MY',\u00a0'EDUCATION'] %%timeit\u00a0 out\u00a0=\u00a0'' for word\u00a0in\u00a0input: out\u00a0+=\u00a0word<\/code><\/pre>\n<p>The slowest run took 4.22 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>1000000 loops, best of 5: 557 ns per loop<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 join \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u043f\u0430\u043c\u044f\u0442\u044c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u0443 6 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445.<\/em><\/p>\n<\/blockquote>\n<pre><code class=\"python\">%timeit\u00a0out\u00a0=\u00a0'\u00a0'.join(input)<\/code><\/pre>\n<p>The slowest run took 18.70 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 181 ns per loop<\/p>\n<p><\/p>\n<p><strong><em>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0435\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 join! <\/em><\/strong><\/p>\n<hr\/>\n<h3>IV. \u0414\u0430\u0436\u0435 \u0438\u043c\u043f\u043e\u0440\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c!<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 math:<\/p>\n<ul>\n<li>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">import\u00a0math\u00a0 %timeit math.log(2022)<\/code><\/pre>\n<p>The slowest run took 46.74 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 150 ns per loop<\/p>\n<pre><code class=\"python\">from\u00a0math\u00a0import\u00a0log %timeit\u00a0log(2022)<\/code><\/pre>\n<p>The slowest run took 49.43 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>10000000 loops, best of 5: 123 ns per loop<\/p>\n<p>\u0421\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435!<\/p>\n<blockquote>\n<p><em>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 math.log() \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 __getattribute()__ \u0438\u043b\u0438 __getattr()__, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0449\u0435\u0442 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 math \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439.<\/em><\/p>\n<\/blockquote>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u0435\u043d.<\/p>\n<hr\/>\n<h3>V. \u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0439!<\/h3>\n<p><strong>V.I Numpy<\/strong><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c, \u0447\u0442\u043e \u044f\u0437\u044b\u043a\u0438 C\/C++ \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c Python, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0432 \u0432\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u044f\u0437\u044b\u043a\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0422\u0430\u043a, \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 numpy \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 C++, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0439 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438. <\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">a = [i for i in range(50)] b = np.array([i for i in range(50)])<\/code><\/pre>\n<pre><code class=\"python\">%%timeit for i in range(len(a)): a[i] *= 5<\/code><\/pre>\n<p><em>10000 loops, best of 5: 71.4 \u00b5s per loop<\/em><\/p>\n<pre><code class=\"python\">%timeit c = b*5<\/code><\/pre>\n<p>The slowest run took 37.82 times longer than the fastest. This could mean that an intermediate result is being cached.<\/p>\n<p>1000000 loops, best of 5: 845 ns per loop<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e \u0432\u0441\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0443 \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f <strong>\u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>.<\/p>\n<blockquote>\n<p><em>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441<\/em><\/p>\n<\/blockquote>\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-333418","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333418","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=333418"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333418\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}