{"id":426682,"date":"2024-07-19T21:00:32","date_gmt":"2024-07-19T21:00:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=426682"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=426682","title":{"rendered":"<span>Python. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 set \u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439 dict. \u0427\u0430\u0441\u0442\u044c 1 \u0438\u0437 2<\/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<details class=\"spoiler\">\n<summary>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0435\u0440\u043c\u0438\u043d <code>\u0445\u044d\u0448-\u043a\u043e\u0434<\/code> (<code>hash code<\/code>). \u0421\u0438\u043d\u043e\u043d\u0438\u043c\u044b: \u0445\u044d\u0448, \u0445\u0435\u0448, \u0445\u044d\u0448-\u0441\u0443\u043c\u043c\u0430, \u0445\u044d\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (hash value).<\/p>\n<\/li>\n<li>\n<p>\u0422\u0435\u0440\u043c\u0438\u043d\u044b \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0447\u0442\u043e\u0431\u044b: <\/p>\n<ul>\n<li>\n<p>\u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439: \u00ab\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432\u00bb (\u0447\u0442\u043e \u0438\u043c\u0435\u043b\u043e\u0441\u044c \u0432 \u0432\u0438\u0434\u0443?)<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u0442\u044c \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044e<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>\u0422\u0438\u043f\u044b <code>dict<\/code> \u0438 <code>set<\/code> \u0432 Python \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A5%D0%B5%D1%88-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b <code>dict<\/code> \u0438 <code>set<\/code> \u0432 Python?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 Python \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 <code>dict<\/code> \u0438\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>set<\/code>?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0439 <code>dict<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0438?<\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"content\" id=\"content\"><\/a><\/p>\n<h2>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<ul>\n<li>\n<p><a href=\"#1\" rel=\"noopener noreferrer nofollow\">1. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#2\" rel=\"noopener noreferrer nofollow\">2. \u0425\u044d\u0448\u0438 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e (equality)<\/a> <\/p>\n<ul>\n<li>\n<p><a href=\"#2-1\" rel=\"noopener noreferrer nofollow\">2.1 \u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0445\u044d\u0448\u0430<\/a><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"#3\" rel=\"noopener noreferrer nofollow\">3. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 <\/a><code>set<\/code><\/p>\n<ul>\n<li>\n<p><a href=\"#3-1\" rel=\"noopener noreferrer nofollow\">3.1. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3-2\" rel=\"noopener noreferrer nofollow\">3.2. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <\/a><code>set<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>4. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 <code>dict<\/code> <\/p>\n<ul>\n<li>\n<p>4.1. \u041a\u0430\u043a \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 <code>dict<\/code> \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043c\u0435\u0441\u0442\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>4.2 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 <code>dict<\/code><\/p>\n<\/li>\n<li>\n<p>4.3. <code>dict<\/code> \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u043a\u043b\u044e\u0447\u0430\u043c<\/p>\n<\/li>\n<li>\n<p>4.4. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>dict<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"https:\/\/notes\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/a><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>? \u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0434\u0435\u0442\u0430\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430. \u041d\u043e \u0438\u0434\u0435\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438\u0445 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u043c <a href=\"#3-2\" rel=\"noopener noreferrer nofollow\">3.2. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <\/a><code>set<\/code> \u0438 4.4. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>dict<\/code>.<\/p>\n<\/blockquote>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>dict<\/code> \u0438 <code>set<\/code> \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h2>1. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e<\/h2>\n<blockquote>\n<p>? \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <a href=\"https:\/\/github.com\/AllenDowney\/fluent-python-notebooks\/tree\/master\/03-dict-set\/support\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/AllenDowney\/fluent-python-notebooks\/tree\/master\/03-dict-set\/support<\/a><\/p>\n<\/blockquote>\n<p>\u041f\u043e \u043e\u043f\u044b\u0442\u0443 \u0432\u0441\u0435 \u043f\u0438\u0442\u043e\u043d\u0438\u0441\u0442\u044b \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e <code>dict<\/code> \u0438 <code>set<\/code> \u2014 \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e. \u041c\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0440 <code>dict<\/code>, <code>set<\/code> \u0438\u043b\u0438 <code>list<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>in<\/code>, \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 10 \u043c\u043b\u043d \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0442\u0438\u043f\u0430 <code>float<\/code> \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <code>haystack<\/code> (<em>\u0441\u0442\u043e\u0433 \u0441\u0435\u043d\u0430<\/em>). \u0417\u0430\u0442\u0435\u043c \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043c\u0430\u0441\u0441\u0438\u0432: 1000 \u0447\u0438\u0441\u0435\u043b \u0442\u0438\u043f\u0430 <code>float<\/code>, 500 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u0438\u0437 <code>haystack<\/code>, \u0430 500 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b \u043d\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u043d\u0435\u043c \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0443\u0442 <code>needles<\/code> (<em>\u0438\u0433\u043e\u043b\u043a\u0438<\/em>).<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>dict<\/code> \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <code>dict.fromkeys()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>dict<\/code> \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>haystack<\/code> \u0441 1000 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 <code>float<\/code>. \u042d\u0442\u043e \u0441\u0435\u0442\u0430\u043f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 <code>dict<\/code>. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0437\u0430\u0441\u0435\u043a\u0430\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f <code>timeit<\/code>, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 <a href=\"#primer-1\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0435 1<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"primer-1\" id=\"primer-1\"><\/a><\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 1. \u041f\u043e\u0438\u0441\u043a <\/em><code>needles<\/code> \u0432 <code>haystack<\/code> \u0438 \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"python\">found = 0 for n in needles:     if n in haystack:         found += 1<\/code><\/pre>\n<p>\u042f \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043b \u0442\u0435\u0441\u0442 \u043f\u044f\u0442\u044c \u0440\u0430\u0437, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043c\u0435\u0440 <code>haystack<\/code> \u0432 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437, \u043e\u0442 1000 \u0434\u043e 10 \u043c\u043b\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0430 <a href=\"#ris-1\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 1<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"ris-1\" id=\"ris-1\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/272\/70c\/a68\/27270ca6863626e8ff7429489b29feb4.png\" alt=\"\u0420\u0438\u0441. 1.\" title=\"\u0420\u0438\u0441. 1.\" width=\"937\" height=\"322\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/272\/70c\/a68\/27270ca6863626e8ff7429489b29feb4.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 1.<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e, \u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u044f 1000 \u043a\u043b\u044e\u0447\u0435\u0439 \u0442\u0438\u043f\u0430 <code>float<\/code> \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0441 1000 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e 0.099 \u043c\u0441, \u0430 \u0442\u043e\u0442 \u0436\u0435 \u043f\u043e\u0438\u0441\u043a \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0441 10 \u043c\u043b\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0437\u0430\u043d\u044f\u043b 0.512 \u043c\u0441. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>haystack<\/code> \u0441 10 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e 0,512 \u043c\u0441. \u0414\u0430, \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043d\u0430 \u0438\u0433\u043e\u043b\u043a\u0443 (\u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 <code>needles<\/code>). \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0430\u043b\u043e \u0432 10\u00a0000 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435, \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e\u0441\u044c \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 5 \u0440\u0430\u0437. \u041c\u0438\u043b\u043e.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438, \u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043b \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0441 \u0442\u0435\u043c \u0436\u0435 <code>haystack<\/code> \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043d\u043e \u0445\u0440\u0430\u043d\u044f \u0435\u0433\u043e \u043a\u0430\u043a <code>set<\/code> \u0438 \u043a\u0430\u043a <code>list<\/code>. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 <code>set<\/code>, \u043f\u043e\u043c\u0438\u043c\u043e \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430 \u0446\u0438\u043a\u043b\u0430 <code>for<\/code> \u0432 <a href=\"#primer-1\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0435 1<\/a>, \u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0441\u0435\u043a\u0430\u043b \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0430: <a href=\"#primer-2\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440 2<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 <code>needles<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 <code>haystack<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0431\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <code>set<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"primer-2\" id=\"primer-2\"><\/a><\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 2. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0438\u0433\u043e\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 <\/em><code>haystack<\/code><\/p>\n<pre><code class=\"python\">found = len(needles &amp; haystack)<\/code><\/pre>\n<p>\u041d\u0430 <a href=\"#ris-2\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 2<\/a> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432 \u0440\u044f\u0434\u043e\u043c \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u041d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <code>set&amp; time<\/code>, \u0433\u0434\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>set<\/code> <code>&amp;<\/code> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0438\u0437 <a href=\"#primer-2\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0430 2<\/a>. \u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u0445\u0443\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <code>list time<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>in<\/code> \u0432 <code>list<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>needles<\/code> (\u0438\u0433\u043e\u043b\u043a\u0430) \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0441\u0442\u0435\u0442 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <code>haystack<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"ris-2\" id=\"ris-2\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a5f\/b31\/6f3\/a5fb316f3423b9d6244e5598eb4dd6bd.png\" alt=\"\u0420\u0438\u0441. 2.\" title=\"\u0420\u0438\u0441. 2.\" width=\"951\" height=\"323\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5f\/b31\/6f3\/a5fb316f3423b9d6244e5598eb4dd6bd.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 2.<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u044e\u0431\u043e\u0439 \u0432\u0438\u0434 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0439 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u0445 \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u043f\u043e\u043a\u0430 \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438).<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b <code>dict<\/code> \u0438 <code>set<\/code>, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0445\u044d\u0448-\u043a\u043e\u0434\u0430\u0445 \u0438 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u043d\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e\u043c.<\/p>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h2>2. \u0425\u044d\u0448\u0438 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e (equality)<\/h2>\n<p>Built-in \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>hash()<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 built-in \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 <code>__hash__<\/code> \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0415\u0441\u043b\u0438 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u0438\u0445 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438, \u0438\u043d\u0430\u0447\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>1 == 1.0<\/code> \u2014 \u044d\u0442\u043e <code>True<\/code>, \u0442\u043e <code>hash(1) == hash(1.0)<\/code> \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c True, \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>int<\/code> \u0438 <code>float<\/code> \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f<a href=\"#notes-1\" rel=\"noopener noreferrer nofollow\">(1)<\/a>.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446, \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u044b \u043f\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0445\u043e\u0436\u0438, \u043d\u043e \u043d\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0445\u044d\u0448-\u043a\u043e\u0434\u044b. <a href=\"#primer-3\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440 3<\/a> \u2014 \u0432\u044b\u0432\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0445\u044d\u0448\u0435\u0439. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0445\u044d\u0448-\u043a\u043e\u0434\u044b <code>1<\/code> \u0438 <code>1.0<\/code> \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u0430 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b <code>1.0001<\/code>, <code>1.0002<\/code> \u0438 <code>1.0003<\/code> \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p><a class=\"anchor\" name=\"primer-3\" id=\"primer-3\"><\/a><\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 3.<\/em> \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0445\u044d\u0448\u0435\u0439 1, 1.0001, 1.0002 \u0438 1.0003 \u043d\u0430 32-\u0431\u0438\u0442\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 Python (\u0431\u0438\u0442\u044b, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0445\u044d\u0448\u0430\u0445 \u0432\u044b\u0448\u0435 \u0438 \u043d\u0438\u0436\u0435, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c <code>!<\/code>, \u0430 \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0431\u0438\u0442\u043e\u0432)<\/p>\n<pre><code class=\"cpp\">32-bit Python build 1        00000000000000000000000000000001                                           != 0 1.0      00000000000000000000000000000001 ------------------------------------------------ 1.0      00000000000000000000000000000001            ! !!! ! !! ! !    ! ! !! !!!   != 16 1.0001   00101110101101010000101011011101 ------------------------------------------------ 1.0001   00101110101101010000101011011101           !!!  !!!! !!!!!   !!!!! !!  !   != 20 1.0002   01011101011010100001010110111001 ------------------------------------------------ 1.0002   01011101011010100001010110111001           ! !   ! !!! ! !  !! ! !  ! !!!! != 17 1.0003   00001100000111110010000010010110 ------------------------------------------------<\/code><\/pre>\n<blockquote>\n<p>? \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.3, \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0445\u044d\u0448\u0435\u0439 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>str<\/code>, <code>bytes<\/code> \u0438 <code>datetime<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BE%D0%BB%D1%8C_(%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F)\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u043b\u0438<\/a>, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0432\u044b\u043f\u0443\u0441\u043a\u0435 <a href=\"https:\/\/bugs.python.org\/issue13703\" rel=\"noopener noreferrer nofollow\">13703-Hash collision security issue<\/a>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 Python, \u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430. \u0412 PEP-456 Python 3.4 \u043f\u0440\u0438\u043d\u044f\u043b \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>SipHash<\/code> \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0435\u0439 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>str<\/code> \u0438 <code>bytes<\/code>. \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0441\u043e\u043b\u044c \u0438 <code>SipHash<\/code> \u2014 \u044d\u0442\u043e \u043c\u0435\u0440\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f DoS-\u0430\u0442\u0430\u043a. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a <a href=\"https:\/\/docs.python.org\/3\/reference\/datamodel.html#object.__hash__\" rel=\"noopener noreferrer nofollow\">\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443 <\/a><code>__hash__<\/code>.<\/p>\n<\/blockquote>\n<p><a class=\"anchor\" name=\"2-1\" id=\"2-1\"><\/a><\/p>\n<h3>2.1 \u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0445\u044d\u0448\u0430<\/h3>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u0432 64-\u0431\u0438\u0442\u043d\u043e\u043c CPython \u0445\u044d\u0448-\u043a\u043e\u0434 \u2014 \u044d\u0442\u043e 64-\u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0430 \u044d\u0442\u043e 2\u2076\u2074 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 10\u00b9\u2079. \u041d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 Python \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0437 10 \u043f\u0435\u0447\u0430\u0442\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 ASCII, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0443\u0433\u0430\u0434, \u0438\u043c\u0435\u0435\u0442 100\u00b9\u2070 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u2014 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 2\u2076\u2076. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u044d\u0448-\u043a\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0445\u044d\u0448.<\/p>\n<blockquote>\n<p>? \u041f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043d\u0435\u0432\u0435\u0440\u043d\u043e: \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b. \u041a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0445\u044d\u0448 \u2014 \u044d\u0442\u043e \u0445\u044d\u0448-\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u0418\u043c\u0435\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0445\u044d\u0448\u0430\u0445 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0445\u044d\u0448-\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439.<\/p>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h2>3. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 set<\/h2>\n<p>\u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>set<\/code>.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <code>set<\/code> \u0441 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0434\u043d\u0435\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">>>> workdays = {'Mon', 'Tue', 'Wed', 'Thu', 'Fri'} >>> workdays {'Tue', 'Mon', 'Wed', 'Fri', 'Thu'}<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 <code>set<\/code> \u0432 Python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 8 \u0441\u0442\u0440\u043e\u043a. \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <code>buckets<\/code><a href=\"#notes-2\" rel=\"noopener noreferrer nofollow\">(2)<\/a>.<\/p>\n<p>\u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0434\u043d\u0435\u0439, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 <a href=\"#ris-3\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 3<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"ris-3\" id=\"ris-3\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b6f\/87d\/a43\/b6f87da43a28bc34af42d7afe8b1ed11.png\" alt=\"\u0420\u0438\u0441. 3. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}. \u041a\u0430\u0436\u0434\u044b\u0439 bucket \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041f\u0443\u0441\u0442\u044b\u0435 buckets \u0438\u043c\u0435\u044e\u0442 -1 \u0432 \u043f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430. \u0423\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\" title=\"\u0420\u0438\u0441. 3. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}. \u041a\u0430\u0436\u0434\u044b\u0439 bucket \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041f\u0443\u0441\u0442\u044b\u0435 buckets \u0438\u043c\u0435\u044e\u0442 -1 \u0432 \u043f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430. \u0423\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\" width=\"2412\" height=\"711\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6f\/87d\/a43\/b6f87da43a28bc34af42d7afe8b1ed11.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 3<\/em>. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> <code>{'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}<\/code>. \u041a\u0430\u0436\u0434\u044b\u0439 <code>bucket<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041f\u0443\u0441\u0442\u044b\u0435 <code>buckets<\/code> \u0438\u043c\u0435\u044e\u0442 <code>-1<\/code> \u0432 \u043f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430. \u0423\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 CPython, \u0434\u043b\u044f 64-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u043a\u0430\u0436\u0434\u044b\u0439 <code>bucket<\/code> \u0432 <code>set<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: 64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c Python, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>buckets<\/code> \u0438\u043c\u0435\u044e\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c <code>buckets<\/code> \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043e\u0442 0 \u0434\u043e 7 \u043d\u0430 <a href=\"#ris-3\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 3<\/a> \u043d\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p><a class=\"anchor\" name=\"3-1\" id=\"3-1\"><\/a><\/p>\n<h3>3.1. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 <code>set<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0430 <code>dict<\/code>.<\/p>\n<blockquote>\n<p>? \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>set<\/code>. \u0412\u0441\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 CPython \u0434\u043b\u044f <code>set<\/code> \u0438 <code>frozenset<\/code> \u0432 <a href=\"https:\/\/github.com\/python\/cpython\/blob\/master\/Include\/setobject.h\" rel=\"noopener noreferrer nofollow\">Include\/setobject.h<\/a> \u0438 <a href=\"https:\/\/github.com\/python\/cpython\/blob\/master\/Objects\/setobject.c\" rel=\"noopener noreferrer nofollow\">Objects\/setobject.c<\/a>.<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a Python \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>set<\/code> <code>{'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}<\/code>, \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u043e\u0439 \u043d\u0430 <a href=\"#ris-4\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 4<\/a> \u0438 \u043e\u043f\u0438\u0441\u0430\u043d \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p><a class=\"anchor\" name=\"ris-4\" id=\"ris-4\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b48\/e8a\/382\/b48e8a382ccadebfcaae41ac21f4377f.png\" alt=\"\u0420\u0438\u0441. 4. \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\" title=\"\u0420\u0438\u0441. 4. \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\" width=\"2600\" height=\"1400\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b48\/e8a\/382\/b48e8a382ccadebfcaae41ac21f4377f.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 4.<\/em> \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430<\/figcaption><\/div>\n<\/figure>\n<h4>\u0428\u0430\u0433 0: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h4>\n<p>\u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 8 \u043f\u0443\u0441\u0442\u044b\u0445 <code>bucket<\/code>. \u041f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, Python \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u2153 <code>buckets<\/code> \u0431\u044b\u043b\u0438 \u043f\u0443\u0441\u0442\u044b\u043c\u0438, \u0443\u0434\u0432\u0430\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430. \u041f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>bucket<\/code> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <code>-1<\/code>, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043d\u0435\u0442 \u0445\u044d\u0448\u0430\u00bb<a href=\"#notes-3\" rel=\"noopener noreferrer nofollow\">(3)<\/a>.<\/p>\n<h4>\u0428\u0430\u0433 1: \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0445\u044d\u0448\u0430 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/h4>\n<p>\u0414\u043b\u044f <code>{'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}<\/code>, Python \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, <code>'Mon'<\/code>. \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430 \u0434\u043b\u044f <code>'Mon'<\/code> \u2014 \u0432\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437-\u0437\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0441\u043e\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code class=\"python\">>>> hash('Mon') 4199492796428269555<\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u0445\u044d\u0448\u0430<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, Python \u0431\u0435\u0440\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u2014 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0430 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0417\u0434\u0435\u0441\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0440\u0430\u0432\u0435\u043d 8, \u0430 \u043c\u043e\u0434\u0443\u043b\u044c \u0440\u0430\u0432\u0435\u043d 3:<\/p>\n<pre><code class=\"python\">>>> 4199492796428269555 % 8 3<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u0437 \u0445\u044d\u0448\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e <code>bucket<\/code> \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 Python \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 <code>bucket<\/code> \u043f\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e <code>3<\/code> \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 <code>-1<\/code> \u0432 \u043f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044f \u043f\u0443\u0441\u0442\u043e\u0439 <code>bucket<\/code>.<\/p>\n<h4>\u0428\u0430\u0433 3: \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043f\u0443\u0441\u0442\u043e\u0439 bucket<\/h4>\n<p>Python \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>4199492796428269555<\/code> \u0432 \u043f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430 \u043f\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e <code>3<\/code> \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>'Mon'<\/code> \u0432 \u043f\u043e\u043b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u041d\u0430 <a href=\"#ris-5\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 5<\/a> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p><a class=\"anchor\" name=\"ris-5\" id=\"ris-5\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/650\/648\/012\/650648012a740b82b38cc050d1a3a2ce.png\" alt=\"\u0420\u0438\u0441. 5. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon'}\" title=\"\u0420\u0438\u0441. 5. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon'}\" width=\"2412\" height=\"711\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/650\/648\/012\/650648012a740b82b38cc050d1a3a2ce.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 5.<\/em> \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> <code>{'Mon'}<\/code><\/figcaption><\/div>\n<\/figure>\n<h4>\u0428\u0430\u0433\u0438 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/h4>\n<p>\u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, <code>'Tue'<\/code>, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0448\u0430\u0433\u0438 1, 2, 3, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435. \u0425\u044d\u0448-\u043a\u043e\u0434 \u0434\u043b\u044f <code>'Tue'<\/code> \u2014 <code>2414279730484651250<\/code>, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u2014 <code>2<\/code>.<\/p>\n<pre><code class=\"python\">>>> hash('Tue') 2414279730484651250 >>> hash('Tue') % 8 2<\/code><\/pre>\n<p>\u0425\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>'Tue'<\/code> \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 <code>bucket<\/code> <code>2<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u043b \u043f\u0443\u0441\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <a href=\"#ris-6\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 6<\/a><\/p>\n<p><a class=\"anchor\" name=\"ris-6\" id=\"ris-6\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f3a\/06a\/f5d\/f3a06af5db394fd858372d03ab1445bc.png\" alt=\"\u0420\u0438\u0441. 6. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue'}. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f.\" title=\"\u0420\u0438\u0441. 6. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue'}. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f.\" width=\"2412\" height=\"711\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f3a\/06a\/f5d\/f3a06af5db394fd858372d03ab1445bc.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 6.<\/em> \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> <code>{'Mon', 'Tue'}<\/code>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f.<\/figcaption><\/div>\n<\/figure>\n<h4>\u0428\u0430\u0433\u0438 \u043f\u0440\u0438 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438<\/h4>\n<p>\u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 <code>'Wed'<\/code> \u0432 <code>set<\/code>, Python \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 (<code>-5145319347887138165<\/code>) \u0438 \u0438\u043d\u0434\u0435\u043a\u0441 (<code>3<\/code>). Python \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 <code>bucket<\/code> <code>3<\/code> \u0438 \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e \u043e\u043d \u0443\u0436\u0435 \u0437\u0430\u043d\u044f\u0442. \u041d\u043e \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0439\u0441\u044f \u0442\u0430\u043c \u0445\u044d\u0448-\u043a\u043e\u0434 <code>4199492796428269555<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <a href=\"#2\" rel=\"noopener noreferrer nofollow\">2. \u0425\u044d\u0448\u0438 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e (equality)<\/a>, \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b, \u0442\u043e \u0438 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u0436\u0435 \u0440\u0430\u0437\u043d\u043e\u0435. \u042d\u0442\u043e <strong><em>\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/em><\/strong>. \u0417\u0430\u0442\u0435\u043c Python \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>bucket<\/code> \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u043f\u0443\u0441\u0442\u044b\u043c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <code>'Wed'<\/code> \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 <code>4<\/code>, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 <a href=\"#ris-7\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 7<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"ris-7\" id=\"ris-7\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0c6\/a2c\/caa\/0c6a2ccaa903d27b3c20ad0a4e7fe4cb.png\" alt=\"\u0420\u0438\u0441. 7. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue', 'Wed'}. \u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438, 'Wed' \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0438\u043d\u0434\u0435\u043a\u0441 4\" title=\"\u0420\u0438\u0441. 7. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue', 'Wed'}. \u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438, 'Wed' \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0438\u043d\u0434\u0435\u043a\u0441 4\" width=\"2414\" height=\"710\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0c6\/a2c\/caa\/0c6a2ccaa903d27b3c20ad0a4e7fe4cb.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 7.<\/em> \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> <code>{'Mon', 'Tue', 'Wed'}<\/code>. \u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438, <code>'Wed'<\/code> \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0438\u043d\u0434\u0435\u043a\u0441 <code>4<\/code><\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>'Thu'<\/code> \u0441\u043a\u0443\u0447\u043d\u043e: \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u043d\u0435\u0442 \u0438 \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0441\u0432\u043e\u0439 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 <code>bucket<\/code>, \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>7<\/code>.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <code>'Fri'<\/code> \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u0415\u0433\u043e \u0445\u044d\u0448-\u043a\u043e\u0434 <code>7021641685991143771<\/code> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 <code>3<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043d\u044f\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c <code>'Mon'<\/code>. \u041e\u043f\u0440\u043e\u0441\u0438\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>bucket<\/code> (\u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c <code>4<\/code>), Python \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u043c \u0445\u044d\u0448-\u043a\u043e\u0434 \u0434\u043b\u044f <code>'Wed'<\/code>. \u0425\u044d\u0448-\u043a\u043e\u0434\u044b \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. Python \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <code>bucket<\/code>. \u041e\u043d \u043f\u0443\u0441\u0442\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>'Fri'<\/code> \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 <code>5<\/code>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 <a href=\"#ris-8\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 8<\/a>.<\/p>\n<blockquote>\n<p>? \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9B%D0%B8%D0%BD%D0%B5%D0%B9%D0%BD%D0%BE%D0%B5_%D0%B7%D0%BE%D0%BD%D0%B4%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\" rel=\"noopener noreferrer nofollow\"><strong><em>\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u0437\u043e\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c<\/em><\/strong><\/a> (linear probing). \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0439 (\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432) \u0437\u0430\u043d\u044f\u0442\u044b\u0445 <code>buckets<\/code>, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u0445\u0443\u0434\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 CPython \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0437\u043e\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0438\u0442\u043e\u0432 \u0445\u044d\u0448\u0430. \u042d\u0442\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u0430 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 <code>set<\/code>.<\/p>\n<\/blockquote>\n<p><a class=\"anchor\" name=\"ris-8\" id=\"ris-8\"><\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/879\/6ae\/c90\/8796aec9059e38a1df6e4bd46ef48991.png\" alt=\"\u0420\u0438\u0441. 8. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043d\u0430 62,5% \u0438 \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043f\u043e\u0440\u043e\u0433\u0443 \u2154\" title=\"\u0420\u0438\u0441. 8. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f set {'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043d\u0430 62,5% \u0438 \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043f\u043e\u0440\u043e\u0433\u0443 \u2154\" width=\"2412\" height=\"711\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/879\/6ae\/c90\/8796aec9059e38a1df6e4bd46ef48991.png\"\/><\/p>\n<div><figcaption><em>\u0420\u0438\u0441. 8.<\/em> \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> <code>{'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043d\u0430 62,5% \u0438 \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043f\u043e\u0440\u043e\u0433\u0443 \u2154<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u043e\u043c <code>bucket<\/code> \u0435\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, Python \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e, \u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <a href=\"#2-1\" rel=\"noopener noreferrer nofollow\">2.1 \u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0445\u044d\u0448\u0430<\/a>, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0445\u044d\u0448, \u0445\u043e\u0442\u044f \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u044d\u0442\u043e \u0440\u0435\u0434\u043a\u043e\u0441\u0442\u044c, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <code>Siphash<\/code><a href=\"#notes-4\" rel=\"noopener noreferrer nofollow\">(4)<\/a>. \u042d\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u0445\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a <code>__hash__<\/code>, \u0442\u0430\u043a \u0438 <code>__eq__<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043d\u0430\u0448\u0443 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 \u2154, \u0447\u0442\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u044d\u0442\u043e, Python \u0432\u044b\u0434\u0435\u043b\u0438\u0442 \u043d\u043e\u0432\u0443\u044e \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 16 \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 \u0438 \u0437\u0430\u043d\u043e\u0432\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0443\u0434\u0430 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>set<\/code> \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0431\u0435\u0437 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439, \u0430 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 \u043e\u0434\u043d\u043e\u0439 \u0434\u043e \u0434\u0432\u0443\u0445. \u041f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u043b\u0438\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u044b \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0433\u043e\u0440\u0441\u0442\u043a\u0438 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439.<\/p>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438, \u0441\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0441\u0445\u0435\u043c\u0435 \u043d\u0430 <a href=\"#ris-4\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 4<\/a>.<\/p>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043a <code>set<\/code> <code>s<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e <code>1<\/code>?<\/p>\n<pre><code class=\"python\">>>> s = {1.0, 2.0, 3.0} >>> s.add(1)<\/code><\/pre>\n<p>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>s<\/code> \u0441\u0435\u0439\u0447\u0430\u0441? \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u043b\u0438 <code>1<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>1.0<\/code>? \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0442\u0432\u0435\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u043e\u043b\u0438 Python.<\/p>\n<h4>\u041f\u043e\u0438\u0441\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/h4>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <code>set<\/code> <code>workdays<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 <a href=\"#ris-8\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 8<\/a>. \u0415\u0441\u0442\u044c \u043b\u0438 \u0432 \u043d\u0435\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>'Sat'<\/code>? \u042d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0443\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f <code>'Sat'<\/code> \u0432 <code>workdays<\/code>:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0437\u0432\u0430\u0442\u044c <code>hash('Sat')<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0445\u044d\u0448-\u043a\u043e\u0434. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u044d\u0442\u043e <code>4910012646790914166<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0437 \u0445\u044d\u0448-\u043a\u043e\u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>hash_code % table_size<\/code>. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043d\u0434\u0435\u043a\u0441 \u0440\u0430\u0432\u0435\u043d <code>6<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <code>6<\/code> \u2014 \u043e\u043d\u043e \u043f\u0443\u0441\u0442\u043e\u0435. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e <code>'Sat'<\/code> \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 <code>set<\/code>. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>False<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 <code>set<\/code>. \u0427\u0442\u043e\u0431\u044b \u043e\u0446\u0435\u043d\u0438\u0442\u044c <code>'Thu'<\/code> \u0432 <code>workdays<\/code>:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0437\u0432\u0430\u0442\u044c <code>hash('Tue')<\/code>. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2014 <code>6166047609348267525<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441: <code>6166047609348267525 % 8<\/code> -> <code>5<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <code>5<\/code>: <\/p>\n<ol>\n<li>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0445\u044d\u0448-\u043a\u043e\u0434\u044b. \u041e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c <code>True<\/code>.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0441\u0445\u0435\u043c\u0430 \u043d\u0430 <a href=\"#ris-4\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 4<\/a> \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u0438 \u043a \u043f\u043e\u0438\u0441\u043a\u0443, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u2014 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u0441 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0443\u0433\u043b\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d \u043f\u0443\u0441\u0442\u043e\u0439 <code>bucket<\/code>, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 Python \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>False<\/code>, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0438 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>True<\/code>.<\/p>\n<h3>3.2. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 set<\/h3>\n<p>\u0422\u0438\u043f\u044b <code>set<\/code> \u0438 <code>frozenset<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0445\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u041e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b <code>__hash__<\/code> \u0438 <code>__eq__<\/code> (<em>\u00abPython. \u041a \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c \u043c\u0430\u0441\u0442\u0435\u0440\u0441\u0442\u0432\u0430\u00bb 2-\u0435 \u0438\u0437\u0434. \u2014 \u0421\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u2014 \u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 &#171;\u0445\u044d\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0439&#187;?, \u0441\u0442\u0440. 105<\/em>)<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430. \u0412 <code>set<\/code> \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e <code>bucket<\/code> \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0432 \u0445\u044d\u0448-\u043a\u043e\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u0430\u043c\u0438 \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0431 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u043e\u0433\u043e <code>bucket<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>set<\/code> \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0442\u0440\u0430\u0442 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0431\u044b\u043b \u0431\u044b \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<a href=\"#notes-5\" rel=\"noopener noreferrer nofollow\">(5)<\/a>. \u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043d\u0438\u043c, \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u2153 \u043f\u0443\u0441\u0442\u044b\u0445 <code>buckets<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0438\u0441\u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0438, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0438\u043b\u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0415\u0441\u043b\u0438 \u0434\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438, \u0442\u043e <code>bucket<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043f\u0435\u0440\u0432\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>set<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0434\u0440\u0443\u0433\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b Python \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044f \u0431\u044b \u2153 <code>buckets<\/code> \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438. \u041a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e \u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"notes\" id=\"notes\"><\/a><\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/h2>\n<p><a class=\"anchor\" name=\"notes-1\" id=\"notes-1\"><\/a><\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b <code>int<\/code>, \u0432\u043e\u0442 \u0434\u0435\u0442\u0430\u043b\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 CPython: \u0445\u044d\u0448-\u043a\u043e\u0434 <code>int<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0430\u043c\u043e\u0433\u043e <code>int<\/code>, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0445\u044d\u0448\u0430 <code>-1<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0432\u0435\u043d <code>-2<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"notes-2\" id=\"notes-2\"><\/a><\/p>\n<ol start=\"2\">\n<li>\n<p>\u0421\u043b\u043e\u0432\u043e <code>bucket<\/code> \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u043b\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u0412 Python \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435, \u043d\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0440\u0430\u0441\u043e\u0447\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430.<\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"notes-3\" id=\"notes-3\"><\/a><\/p>\n<ol start=\"3\">\n<li>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>hash()<\/code> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>-1<\/code> \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Python. \u0415\u0441\u043b\u0438 <code>x.hash()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>-1<\/code>, \u0442\u043e <code>hash(x)<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>-2<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"notes-4\" id=\"notes-4\"><\/a><\/p>\n<ol start=\"4\">\n<li>\n<p>\u0412 64-\u0431\u0438\u0442\u043d\u043e\u043c CPython \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0445\u044d\u0448\u0435\u0439 \u0441\u0442\u0440\u043e\u043a \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0434\u043a\u0438, \u0447\u0442\u043e \u044f \u043d\u0435 \u0441\u043c\u043e\u0433 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0439\u0442\u0435 \u043c\u043d\u0435 \u0437\u043d\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"notes-5\" id=\"notes-5\"><\/a><\/p>\n<ol start=\"5\">\n<li>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>  <a href=\"#content\" rel=\"noopener noreferrer nofollow\">\u2191  \u041a \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044e<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/830026\/\"> https:\/\/habr.com\/ru\/articles\/830026\/<\/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<details class=\"spoiler\">\n<summary>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0435\u0440\u043c\u0438\u043d <code>\u0445\u044d\u0448-\u043a\u043e\u0434<\/code> (<code>hash code<\/code>). \u0421\u0438\u043d\u043e\u043d\u0438\u043c\u044b: \u0445\u044d\u0448, \u0445\u0435\u0448, \u0445\u044d\u0448-\u0441\u0443\u043c\u043c\u0430, \u0445\u044d\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (hash value).<\/p>\n<\/li>\n<li>\n<p>\u0422\u0435\u0440\u043c\u0438\u043d\u044b \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0447\u0442\u043e\u0431\u044b: <\/p>\n<ul>\n<li>\n<p>\u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439: \u00ab\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432\u00bb (\u0447\u0442\u043e \u0438\u043c\u0435\u043b\u043e\u0441\u044c \u0432 \u0432\u0438\u0434\u0443?)<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u0442\u044c \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044e<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>\u0422\u0438\u043f\u044b <code>dict<\/code> \u0438 <code>set<\/code> \u0432 Python \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A5%D0%B5%D1%88-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b <code>dict<\/code> \u0438 <code>set<\/code> \u0432 Python?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u044b?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 Python \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 <code>dict<\/code> \u0438\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>set<\/code>?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0439 <code>dict<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0438?<\/p>\n<\/li>\n<\/ul>\n<p><a class=\"anchor\" name=\"content\" id=\"content\"><\/a><\/p>\n<h2>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h2>\n<ul>\n<li>\n<p><a href=\"#1\" rel=\"noopener noreferrer nofollow\">1. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#2\" rel=\"noopener noreferrer nofollow\">2. \u0425\u044d\u0448\u0438 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e (equality)<\/a> <\/p>\n<ul>\n<li>\n<p><a href=\"#2-1\" rel=\"noopener noreferrer nofollow\">2.1 \u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0445\u044d\u0448\u0430<\/a><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"#3\" rel=\"noopener noreferrer nofollow\">3. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 <\/a><code>set<\/code><\/p>\n<ul>\n<li>\n<p><a href=\"#3-1\" rel=\"noopener noreferrer nofollow\">3.1. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3-2\" rel=\"noopener noreferrer nofollow\">3.2. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <\/a><code>set<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>4. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 <code>dict<\/code> <\/p>\n<ul>\n<li>\n<p>4.1. \u041a\u0430\u043a \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 <code>dict<\/code> \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043c\u0435\u0441\u0442\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>4.2 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 <code>dict<\/code><\/p>\n<\/li>\n<li>\n<p>4.3. <code>dict<\/code> \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u043a\u043b\u044e\u0447\u0430\u043c<\/p>\n<\/li>\n<li>\n<p>4.4. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>dict<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><a href=\"https:\/\/notes\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f<\/a><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>? \u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0434\u0435\u0442\u0430\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430. \u041d\u043e \u0438\u0434\u0435\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438\u0445 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u043c <a href=\"#3-2\" rel=\"noopener noreferrer nofollow\">3.2. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <\/a><code>set<\/code> \u0438 4.4. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <code>dict<\/code>.<\/p>\n<\/blockquote>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>dict<\/code> \u0438 <code>set<\/code> \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h2>1. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e<\/h2>\n<blockquote>\n<p>? \u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <a href=\"https:\/\/github.com\/AllenDowney\/fluent-python-notebooks\/tree\/master\/03-dict-set\/support\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/AllenDowney\/fluent-python-notebooks\/tree\/master\/03-dict-set\/support<\/a><\/p>\n<\/blockquote>\n<p>\u041f\u043e \u043e\u043f\u044b\u0442\u0443 \u0432\u0441\u0435 \u043f\u0438\u0442\u043e\u043d\u0438\u0441\u0442\u044b \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e <code>dict<\/code> \u0438 <code>set<\/code> \u2014 \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e. \u041c\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0440 <code>dict<\/code>, <code>set<\/code> \u0438\u043b\u0438 <code>list<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>in<\/code>, \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 10 \u043c\u043b\u043d \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0442\u0438\u043f\u0430 <code>float<\/code> \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <code>haystack<\/code> (<em>\u0441\u0442\u043e\u0433 \u0441\u0435\u043d\u0430<\/em>). \u0417\u0430\u0442\u0435\u043c \u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043c\u0430\u0441\u0441\u0438\u0432: 1000 \u0447\u0438\u0441\u0435\u043b \u0442\u0438\u043f\u0430 <code>float<\/code>, 500 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u044b \u0438\u0437 <code>haystack<\/code>, \u0430 500 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b \u043d\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u043d\u0435\u043c \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0443\u0442 <code>needles<\/code> (<em>\u0438\u0433\u043e\u043b\u043a\u0438<\/em>).<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>dict<\/code> \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <code>dict.fromkeys()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c <code>dict<\/code> \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>haystack<\/code> \u0441 1000 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 <code>float<\/code>. \u042d\u0442\u043e \u0441\u0435\u0442\u0430\u043f \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 <code>dict<\/code>. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0437\u0430\u0441\u0435\u043a\u0430\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0434\u0443\u043b\u044f <code>timeit<\/code>, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 <a href=\"#primer-1\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0435 1<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"primer-1\" id=\"primer-1\"><\/a><\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 1. \u041f\u043e\u0438\u0441\u043a <\/em><code>needles<\/code> \u0432 <code>haystack<\/code> \u0438 \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"python\">found = 0 for n in needles:     if n in haystack:         found += 1<\/code><\/pre>\n<p>\u042f \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043b \u0442\u0435\u0441\u0442 \u043f\u044f\u0442\u044c \u0440\u0430\u0437, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043c\u0435\u0440 <code>haystack<\/code> \u0432 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437, \u043e\u0442 1000 \u0434\u043e 10 \u043c\u043b\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0430 <a href=\"#ris-1\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 1<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"ris-1\" id=\"ris-1\"><\/a><\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u0420\u0438\u0441. 1.<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e, \u0442\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u044f 1000 \u043a\u043b\u044e\u0447\u0435\u0439 \u0442\u0438\u043f\u0430 <code>float<\/code> \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0441 1000 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u043e 0.099 \u043c\u0441, \u0430 \u0442\u043e\u0442 \u0436\u0435 \u043f\u043e\u0438\u0441\u043a \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0441 10 \u043c\u043b\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0437\u0430\u043d\u044f\u043b 0.512 \u043c\u0441. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 <code>haystack<\/code> \u0441 10 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e 0,512 \u043c\u0441. \u0414\u0430, \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043d\u0430 \u0438\u0433\u043e\u043b\u043a\u0443 (\u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 <code>needles<\/code>). \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0430\u043b\u043e \u0432 10\u00a0000 \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435, \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e\u0441\u044c \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432 5 \u0440\u0430\u0437. \u041c\u0438\u043b\u043e.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f\u043c\u0438, \u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043b \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a \u0441 \u0442\u0435\u043c \u0436\u0435 <code>haystack<\/code> \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043d\u043e \u0445\u0440\u0430\u043d\u044f \u0435\u0433\u043e \u043a\u0430\u043a <code>set<\/code> \u0438 \u043a\u0430\u043a <code>list<\/code>. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 <code>set<\/code>, \u043f\u043e\u043c\u0438\u043c\u043e \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430 \u0446\u0438\u043a\u043b\u0430 <code>for<\/code> \u0432 <a href=\"#primer-1\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0435 1<\/a>, \u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0441\u0435\u043a\u0430\u043b \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0430: <a href=\"#primer-2\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440 2<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 <code>needles<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 <code>haystack<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0431\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <code>set<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"primer-2\" id=\"primer-2\"><\/a><\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 2. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0438\u0433\u043e\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 <\/em><code>haystack<\/code><\/p>\n<pre><code class=\"python\">found = len(needles &amp; haystack)<\/code><\/pre>\n<p>\u041d\u0430 <a href=\"#ris-2\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 2<\/a> \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0442\u0435\u0441\u0442\u043e\u0432 \u0440\u044f\u0434\u043e\u043c \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u041d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <code>set&amp; time<\/code>, \u0433\u0434\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>set<\/code> <code>&amp;<\/code> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0438\u0437 <a href=\"#primer-2\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0438\u043c\u0435\u0440\u0430 2<\/a>. \u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u0445\u0443\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <code>list time<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>in<\/code> \u0432 <code>list<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>needles<\/code> (\u0438\u0433\u043e\u043b\u043a\u0430) \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0441\u0442\u0435\u0442 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <code>haystack<\/code>.<\/p>\n<p><a class=\"anchor\" name=\"ris-2\" id=\"ris-2\"><\/a><\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u0420\u0438\u0441. 2.<\/em><\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u044e\u0431\u043e\u0439 \u0432\u0438\u0434 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0439 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u0445 \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u043b\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u043f\u043e\u043a\u0430 \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438).<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b <code>dict<\/code> \u0438 <code>set<\/code>, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0445\u044d\u0448-\u043a\u043e\u0434\u0430\u0445 \u0438 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u043d\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e\u043c.<\/p>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h2>2. \u0425\u044d\u0448\u0438 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e (equality)<\/h2>\n<p>Built-in \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>hash()<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 built-in \u0442\u0438\u043f\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 <code>__hash__<\/code> \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u0415\u0441\u043b\u0438 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u0438\u0445 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438, \u0438\u043d\u0430\u0447\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>1 == 1.0<\/code> \u2014 \u044d\u0442\u043e <code>True<\/code>, \u0442\u043e <code>hash(1) == hash(1.0)<\/code> \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c True, \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>int<\/code> \u0438 <code>float<\/code> \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f<a href=\"#notes-1\" rel=\"noopener noreferrer nofollow\">(1)<\/a>.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446, \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u044b \u043f\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0445\u043e\u0436\u0438, \u043d\u043e \u043d\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0445\u044d\u0448-\u043a\u043e\u0434\u044b. <a href=\"#primer-3\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440 3<\/a> \u2014 \u0432\u044b\u0432\u043e\u0434 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0445\u044d\u0448\u0435\u0439. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0445\u044d\u0448-\u043a\u043e\u0434\u044b <code>1<\/code> \u0438 <code>1.0<\/code> \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b, \u0430 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b <code>1.0001<\/code>, <code>1.0002<\/code> \u0438 <code>1.0003<\/code> \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p><a class=\"anchor\" name=\"primer-3\" id=\"primer-3\"><\/a><\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 3.<\/em> \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0445\u044d\u0448\u0435\u0439 1, 1.0001, 1.0002 \u0438 1.0003 \u043d\u0430 32-\u0431\u0438\u0442\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 Python (\u0431\u0438\u0442\u044b, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0445\u044d\u0448\u0430\u0445 \u0432\u044b\u0448\u0435 \u0438 \u043d\u0438\u0436\u0435, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c <code>!<\/code>, \u0430 \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0431\u0438\u0442\u043e\u0432)<\/p>\n<pre><code class=\"cpp\">32-bit Python build 1        00000000000000000000000000000001                                           != 0 1.0      00000000000000000000000000000001 ------------------------------------------------ 1.0      00000000000000000000000000000001            ! !!! ! !! ! !    ! ! !! !!!   != 16 1.0001   00101110101101010000101011011101 ------------------------------------------------ 1.0001   00101110101101010000101011011101           !!!  !!!! !!!!!   !!!!! !!  !   != 20 1.0002   01011101011010100001010110111001 ------------------------------------------------ 1.0002   01011101011010100001010110111001           ! !   ! !!! ! !  !! ! !  ! !!!! != 17 1.0003   00001100000111110010000010010110 ------------------------------------------------<\/code><\/pre>\n<blockquote>\n<p>? \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.3, \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0445\u044d\u0448\u0435\u0439 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>str<\/code>, <code>bytes<\/code> \u0438 <code>datetime<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BE%D0%BB%D1%8C_(%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F)\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u043b\u0438<\/a>, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0432\u044b\u043f\u0443\u0441\u043a\u0435 <a href=\"https:\/\/bugs.python.org\/issue13703\" rel=\"noopener noreferrer nofollow\">13703-Hash collision security issue<\/a>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 Python, \u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430. \u0412 PEP-456 Python 3.4 \u043f\u0440\u0438\u043d\u044f\u043b \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>SipHash<\/code> \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448\u0435\u0439 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>str<\/code> \u0438 <code>bytes<\/code>. \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0441\u043e\u043b\u044c \u0438 <code>SipHash<\/code> \u2014 \u044d\u0442\u043e \u043c\u0435\u0440\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f DoS-\u0430\u0442\u0430\u043a. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a <a href=\"https:\/\/docs.python.org\/3\/reference\/datamodel.html#object.__hash__\" rel=\"noopener noreferrer nofollow\">\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443 <\/a><code>__hash__<\/code>.<\/p>\n<\/blockquote>\n<p><a class=\"anchor\" name=\"2-1\" id=\"2-1\"><\/a><\/p>\n<h3>2.1 \u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0445\u044d\u0448\u0430<\/h3>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u0432 64-\u0431\u0438\u0442\u043d\u043e\u043c CPython \u0445\u044d\u0448-\u043a\u043e\u0434 \u2014 \u044d\u0442\u043e 64-\u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0430 \u044d\u0442\u043e 2\u2076\u2074 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 10\u00b9\u2079. \u041d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 Python \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0437 10 \u043f\u0435\u0447\u0430\u0442\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 ASCII, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0443\u0433\u0430\u0434, \u0438\u043c\u0435\u0435\u0442 100\u00b9\u2070 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u2014 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 2\u2076\u2076. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u044d\u0448-\u043a\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0445\u044d\u0448.<\/p>\n<blockquote>\n<p>? \u041f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043d\u0435\u0432\u0435\u0440\u043d\u043e: \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b. \u041a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0445\u044d\u0448 \u2014 \u044d\u0442\u043e \u0445\u044d\u0448-\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044f.<\/p>\n<\/blockquote>\n<p>\u0418\u043c\u0435\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0445\u044d\u0448\u0430\u0445 \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0445\u044d\u0448-\u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439.<\/p>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h2>3. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 set<\/h2>\n<p>\u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>set<\/code>.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <code>set<\/code> \u0441 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0434\u043d\u0435\u0439, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">>>> workdays = {'Mon', 'Tue', 'Wed', 'Thu', 'Fri'} >>> workdays {'Tue', 'Mon', 'Wed', 'Fri', 'Thu'}<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 <code>set<\/code> \u0432 Python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 8 \u0441\u0442\u0440\u043e\u043a. \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <code>buckets<\/code><a href=\"#notes-2\" rel=\"noopener noreferrer nofollow\">(2)<\/a>.<\/p>\n<p>\u0425\u0435\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0434\u043d\u0435\u0439, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 <a href=\"#ris-3\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 3<\/a>.<\/p>\n<p><a class=\"anchor\" name=\"ris-3\" id=\"ris-3\"><\/a><\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u0420\u0438\u0441. 3<\/em>. \u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> <code>{'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}<\/code>. \u041a\u0430\u0436\u0434\u044b\u0439 <code>bucket<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041f\u0443\u0441\u0442\u044b\u0435 <code>buckets<\/code> \u0438\u043c\u0435\u044e\u0442 <code>-1<\/code> \u0432 \u043f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430. \u0423\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 CPython, \u0434\u043b\u044f 64-\u0431\u0438\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u043a\u0430\u0436\u0434\u044b\u0439 <code>bucket<\/code> \u0432 <code>set<\/code> \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: 64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c Python, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>buckets<\/code> \u0438\u043c\u0435\u044e\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c <code>buckets<\/code> \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043e\u0442 0 \u0434\u043e 7 \u043d\u0430 <a href=\"#ris-3\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 3<\/a> \u043d\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p><a class=\"anchor\" name=\"3-1\" id=\"3-1\"><\/a><\/p>\n<h3>3.1. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 <code>set<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u043d\u0430 <code>dict<\/code>.<\/p>\n<blockquote>\n<p>? \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>set<\/code>. \u0412\u0441\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 CPython \u0434\u043b\u044f <code>set<\/code> \u0438 <code>frozenset<\/code> \u0432 <a href=\"https:\/\/github.com\/python\/cpython\/blob\/master\/Include\/setobject.h\" rel=\"noopener noreferrer nofollow\">Include\/setobject.h<\/a> \u0438 <a href=\"https:\/\/github.com\/python\/cpython\/blob\/master\/Objects\/setobject.c\" rel=\"noopener noreferrer nofollow\">Objects\/setobject.c<\/a>.<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a Python \u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>set<\/code> <code>{'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}<\/code>, \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u043e\u0439 \u043d\u0430 <a href=\"#ris-4\" rel=\"noopener noreferrer nofollow\">\u0440\u0438\u0441. 4<\/a> \u0438 \u043e\u043f\u0438\u0441\u0430\u043d \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p><a class=\"anchor\" name=\"ris-4\" id=\"ris-4\"><\/a><\/p>\n<figure class=\"full-width\">\n<div><figcaption><em>\u0420\u0438\u0441. 4.<\/em> \u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430<\/figcaption><\/div>\n<\/figure>\n<h4>\u0428\u0430\u0433 0: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h4>\n<p>\u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0434\u043b\u044f <code>set<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 8 \u043f\u0443\u0441\u0442\u044b\u0445 <code>bucket<\/code>. \u041f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, Python \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u2153 <code>buckets<\/code> \u0431\u044b\u043b\u0438 \u043f\u0443\u0441\u0442\u044b\u043c\u0438, \u0443\u0434\u0432\u0430\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430. \u041f\u043e\u043b\u0435 \u0445\u044d\u0448\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>bucket<\/code><\/p>\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-426682","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/426682","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=426682"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/426682\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=426682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=426682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=426682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}