{"id":303258,"date":"2020-05-08T15:01:10","date_gmt":"2020-05-08T15:01:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303258"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303258","title":{"rendered":"\u0417\u0430\u0447\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u0438 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c multithreading \u0438 multiprocessing \u0432 Python"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/501056\/\"><b><i>\u0421\u0430\u043b\u044e\u0442, \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435. \u041f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 OTUS \u043e\u0442\u043a\u0440\u044b\u0442 \u043d\u0430\u0431\u043e\u0440 \u043d\u0430 \u043a\u0443\u0440\u0441 <a href=\"https:\/\/otus.pw\/V1RB\/\">\u00abMachine Learning\u00bb<\/a>, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0441 \u043e\u0434\u043d\u0443 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u00ab\u0441\u043a\u0430\u0437\u043e\u0447\u043a\u0443\u00bb. \u041f\u043e\u0435\u0445\u0430\u043b\u0438.<\/i><\/b><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mi\/su\/ev\/misuevluvampqjc3br79pgtgscg.png\">  <\/p>\n<hr>\n<p>  \u0414\u0430\u0432\u043d\u044b\u043c-\u0434\u0430\u0432\u043d\u043e, \u0432 \u0434\u0430\u043b\u0435\u043a\u043e\u0439-\u0434\u0430\u043b\u0435\u043a\u043e\u0439 \u0433\u0430\u043b\u0430\u043a\u0442\u0438\u043a\u0435\u2026<\/p>\n<p>  \u0416\u0438\u043b \u0432 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0434\u0435\u0440\u0435\u0432\u0443\u0448\u043a\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u0438 \u043f\u0443\u0441\u0442\u044b\u043d\u0438 \u043c\u0443\u0434\u0440\u044b\u0439 \u0438 \u043c\u043e\u0433\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a. \u0418 \u0437\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0414\u0430\u043c\u0431\u043b\u0434\u0430\u043b\u044c\u0444. \u041e\u043d \u0431\u044b\u043b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0443\u0434\u0440 \u0438 \u043c\u043e\u0433\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u0435\u043d, \u043d\u043e \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u043b \u043b\u044e\u0434\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0435\u0437\u0436\u0430\u043b\u0438 \u0438\u0437 \u0434\u0430\u043b\u0435\u043a\u0438\u0445 \u0437\u0435\u043c\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u043c\u043e\u0449\u0438 \u0443 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0430. \u041d\u0430\u0448\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u0438\u043d \u043f\u0443\u0442\u043d\u0438\u043a \u043f\u0440\u0438\u043d\u0435\u0441 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0443 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0432\u0438\u0442\u043e\u043a. \u041f\u0443\u0442\u043d\u0438\u043a \u043d\u0435 \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u0441\u0432\u0438\u0442\u043a\u0435, \u043e\u043d \u043b\u0438\u0448\u044c \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0438 \u0441\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u0439\u043d\u044b \u0441\u0432\u0438\u0442\u043a\u0430, \u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0414\u0430\u043c\u0431\u043b\u0434\u0430\u043b\u044c\u0444.<a name=\"habracut\"><\/a><\/p>\n<h3>\u0413\u043b\u0430\u0432\u0430 1: \u041e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u043e\u0434\u043d\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u044f \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u044e \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c \u0438 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438. \u041d\u0430\u0448 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u0430 \u0441\u0432\u0438\u0442\u043e\u043a \u2013 \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0434\u0443\u0442 \u043a \u0441\u0438\u043b\u0435 Python \u0438 \u0437\u043d\u0430\u043d\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043e\u0432\u043b\u0430\u0434\u0435\u0442\u044c \u0435\u044e.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0439 \u043c\u044b\u0441\u043b\u044c\u044e \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u0430 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043b \u0441\u043f\u0438\u0441\u043e\u043a, \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u0435\u0440\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u0430 (\u0413\u0430\u0440\u0440\u0438\u0433\u043e\u0440\u043d\u0430? \u0417\u043d\u0430\u044e, \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u0443\u0436\u0430\u0441\u043d\u043e) \u0432 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043c\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0441\u0432\u0438\u0442\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0438 \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043c \u043e\u0442\u044b\u0441\u043a\u0430\u0442\u044c.<\/p>\n<pre><code class=\"python\">In [1]: import urllib.request from concurrent.futures import ThreadPoolExecutor In [2]: urls = [   'http:\/\/www.python.org',   'https:\/\/docs.python.org\/3\/',   'https:\/\/docs.python.org\/3\/whatsnew\/3.7.html',   'https:\/\/docs.python.org\/3\/tutorial\/index.html',   'https:\/\/docs.python.org\/3\/library\/index.html',   'https:\/\/docs.python.org\/3\/reference\/index.html',   'https:\/\/docs.python.org\/3\/using\/index.html',   'https:\/\/docs.python.org\/3\/howto\/index.html',   'https:\/\/docs.python.org\/3\/installing\/index.html',   'https:\/\/docs.python.org\/3\/distributing\/index.html',   'https:\/\/docs.python.org\/3\/extending\/index.html',   'https:\/\/docs.python.org\/3\/c-api\/index.html',   'https:\/\/docs.python.org\/3\/faq\/index.html'   ] In [3]: %%time  results = [] for url in urls:     with urllib.request.urlopen(url) as src:         results.append(src)  CPU times: user 135 ms, sys: 283 \u00b5s, total: 135 ms Wall time: 12.3 s In [ ]: <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430 for \u0438 \u0447\u0438\u0442\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <i>%%time<\/i> \u0438 \u043c\u0430\u0433\u0438\u0438 <i>IPython<\/i>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0441 \u043c\u043e\u0438\u043c \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u043e\u043c \u044d\u0442\u043e \u0437\u0430\u043d\u044f\u043b\u043e \u043e\u043a\u043e\u043b\u043e 12 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<h3>\u0413\u043b\u0430\u0432\u0430 2: Multithreading<\/h3>\n<p>  \u041d\u0435\u0441\u043f\u0440\u043e\u0441\u0442\u0430 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u0441\u043b\u0430\u0432\u0438\u043b\u0441\u044f \u0441\u0432\u043e\u0435\u0439 \u043c\u0443\u0434\u0440\u043e\u0441\u0442\u044c\u044e, \u043e\u043d \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043c\u043e\u0433 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443, \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u0442\u0440\u044f\u0434 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0445 \u0441\u043e\u0440\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0438 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043d\u0446\u044b \u0441\u0432\u0435\u0442\u0430 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e! \u0412\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u0441\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0437\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0438 \u043f\u0440\u0438\u043d\u0435\u0441\u0443\u0442!<\/p>\n<p>  \u0412\u0441\u0435 \u0432\u0435\u0440\u043d\u043e, \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>multithreading<\/i> (\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c) \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c URL-\u0430\u0434\u0440\u0435\u0441\u0430\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<pre><code class=\"python\">In [1]: import urllib.request from concurrent.futures import ThreadPoolExecutor In [2]: urls = [   'http:\/\/www.python.org',   'https:\/\/docs.python.org\/3\/',   'https:\/\/docs.python.org\/3\/whatsnew\/3.7.html',   'https:\/\/docs.python.org\/3\/tutorial\/index.html',   'https:\/\/docs.python.org\/3\/library\/index.html',   'https:\/\/docs.python.org\/3\/reference\/index.html',   'https:\/\/docs.python.org\/3\/using\/index.html',   'https:\/\/docs.python.org\/3\/howto\/index.html',   'https:\/\/docs.python.org\/3\/installing\/index.html',   'https:\/\/docs.python.org\/3\/distributing\/index.html',   'https:\/\/docs.python.org\/3\/extending\/index.html',   'https:\/\/docs.python.org\/3\/c-api\/index.html',   'https:\/\/docs.python.org\/3\/faq\/index.html'   ] In [4]: %%time  with ThreadPoolExecutor(4) as executor:     results = executor.map(urllib.request.urlopen, urls)  CPU times: user 122 ms, sys: 8.27 ms, total: 130 ms Wall time: 3.83 s In [5]: %%time  with ThreadPoolExecutor(8) as executor:     results = executor.map(urllib.request.urlopen, urls)  CPU times: user 122 ms, sys: 14.7 ms, total: 137 ms Wall time: 1.79 s In [6]: %%time  with ThreadPoolExecutor(16) as executor:     results = executor.map(urllib.request.urlopen, urls)  CPU times: user 143 ms, sys: 3.88 ms, total: 147 ms Wall time: 1.32 s In [ ]: <\/code><\/pre>\n<p>  \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435! \u041f\u043e\u0447\u0442\u0438 \u043a\u0430\u043a\u2026 \u043c\u0430\u0433\u0438\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c-\u0432\u044b\u0432\u043e\u0434\u043e\u043c. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 URL-\u0430\u0434\u0440\u0435\u0441\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430\u043c\u0438 \u0441\u0435\u0442\u0438. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a \u0432\u0432\u043e\u0434\u0443-\u0432\u044b\u0432\u043e\u0434\u0443, \u043f\u0440\u043e\u0432\u043e\u0434\u044f\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438, \u043a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u0432\u0432\u043e\u0434\u0430 \u0438\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 (\u043f\u043e\u0434\u043e\u0431\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u0436\u0434\u0435\u0442, \u043f\u043e\u043a\u0430 \u0435\u0433\u043e \u0434\u0440\u0443\u0437\u044c\u044f \u0441\u044a\u0435\u0437\u0434\u044f\u0442 \u0432 \u043c\u0435\u0441\u0442\u0430 \u0438\u0437 \u0441\u0432\u0438\u0442\u043a\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e). \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434 \u0438\u0437 \u0441\u0435\u0442\u0438, \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u0430\u043a\u043e\u0439 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434 \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0432\u0432\u043e\u0434-\u0432\u044b\u0432\u043e\u0434. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 (\u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e, \u043a\u0430\u043a \u0424\u043b\u044d\u0448 \u043f\u0440\u043e\u0442\u0438\u0432 \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0431\u0443\u0448\u043a\u0438).<\/p>\n<p>  <i><b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: <code>multithreading<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u043a\u0430\u043a \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446.<\/i><\/p>\n<h3>\u0413\u043b\u0430\u0432\u0430 3: Multiprocessing<\/h3>\n<p>  \u0428\u043b\u0438 \u0433\u043e\u0434\u044b, \u0441\u043b\u0430\u0432\u0430 \u043e \u0434\u043e\u0431\u0440\u043e\u043c \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0435 \u0440\u043e\u0441\u043b\u0430, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0435\u0439 \u0440\u043e\u0441\u043b\u0430 \u0438 \u0437\u0430\u0432\u0438\u0441\u0442\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0435\u043b\u0438\u0446\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0430 (\u0421\u0430\u0440\u0443\u043c\u043e\u0440\u0442\u0430? \u0418\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0412\u043e\u043b\u0430\u043d\u0434\u0435\u043c\u0430\u043d\u0430?). \u0412\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u043c\u0435\u0440\u044f\u043d\u043e\u0439 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c\u044e \u0438 \u0434\u0432\u0438\u0436\u0438\u043c\u044b\u0439 \u0437\u0430\u0432\u0438\u0441\u0442\u044c\u044e, \u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u043d\u0430\u043b\u043e\u0436\u0438\u043b \u043d\u0430 \u0414\u0430\u043c\u0431\u043b\u0434\u0430\u043b\u044c\u0444\u0430 \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0435 \u043f\u0440\u043e\u043a\u043b\u044f\u0442\u0438\u0435. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043a\u043b\u044f\u0442\u0438\u0435 \u043d\u0430\u0441\u0442\u0438\u0433\u043b\u043e \u0435\u0433\u043e, \u0414\u0430\u043c\u0431\u043b\u0434\u0430\u043b\u044c\u0444 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c \u0435\u0433\u043e. \u0412 \u043e\u0442\u0447\u0430\u044f\u043d\u0438\u0438 \u043e\u043d \u0440\u044b\u043b\u0441\u044f \u0432 \u0441\u0432\u043e\u0438\u0445 \u043a\u043d\u0438\u0433\u0430\u0445 \u0437\u0430\u043a\u043b\u0438\u043d\u0430\u043d\u0438\u0439 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0448\u0435\u043b \u043e\u0434\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u0437\u0430\u043a\u043b\u044f\u0442\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0443 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043c\u0435\u043d\u044c\u0448\u0435 1 000 000. \u0421\u0442\u0440\u0430\u043d\u043d\u043e\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0437\u0430\u043a\u043b\u044f\u0442\u044c\u0435, \u043d\u043e \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u043c. <\/p>\n<p>  \u0412\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u043e\u0441\u043a\u043e\u0448\u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0432\u0435\u043b\u0438\u043a\u0438\u0439 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a, \u0432\u0441\u0435 \u0436\u0435 \u0438 \u043e\u043d \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0441\u0432\u043e\u0435\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0437\u0430 \u0440\u0430\u0437. \u0415\u0441\u043b\u0438 \u0431\u044b \u043e\u043d \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c, \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0448\u043b\u043e \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e. \u041a\u043e\u0433\u0434\u0430 \u0434\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0437\u0430\u043a\u043b\u044f\u0442\u044c\u0435 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043e\u043d \u0432\u0434\u0440\u0443\u0433 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u0437\u0430\u043a\u043b\u044f\u0442\u044c\u0435 <i>multiprocessing<\/i>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0437\u043d\u0430\u043b \u0438\u0437 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0432\u0438\u0442\u043a\u0430 \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434. \u042d\u0442\u043e \u0437\u0430\u043a\u043b\u0438\u043d\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0435\u043c\u0443 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0431\u044f, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u043e\u0438\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0418 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0438 \u0435\u0433\u043e \u043a\u043e\u043f\u0438\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0430\u0442.<\/p>\n<pre><code class=\"python\">In [1]: from multiprocessing import Pool In [2]: def if_prime(x):     if x &lt;= 1:         return 0     elif x &lt;= 3:         return x     elif x % 2 == 0 or x % 3 == 0:         return 0     i = 5     while i**2 &lt;= x:         if x % i == 0 or x % (i + 2) == 0:             return 0         i += 6     return x In [17]: %%time  answer = 0  for i in range(1000000):     answer += if_prime(i)  CPU times: user 3.48 s, sys: 0 ns, total: 3.48 s Wall time: 3.48 s In [18]: %%time  if __name__ == '__main__':     with Pool(2) as p:         answer = sum(p.map(if_prime, list(range(1000000))))  CPU times: user 114 ms, sys: 4.07 ms, total: 118 ms Wall time: 1.91 s In [19]: %%time  if __name__ == '__main__':     with Pool(4) as p:         answer = sum(p.map(if_prime, list(range(1000000))))  CPU times: user 99.5 ms, sys: 30.5 ms, total: 130 ms Wall time: 1.12 s In [20]: %%timeit  if __name__ == '__main__':     with Pool(8) as p:         answer = sum(p.map(if_prime, list(range(1000000))))  729 ms \u00b1 3.02 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each) In [21]: %%timeit  if __name__ == '__main__':     with Pool(16) as p:         answer = sum(p.map(if_prime, list(range(1000000))))  512 ms \u00b1 39.8 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each) In [22]: %%timeit  if __name__ == '__main__':     with Pool(32) as p:         answer = sum(p.map(if_prime, list(range(1000000))))  518 ms \u00b1 13.3 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each) In [23]: %%timeit  if __name__ == '__main__':     with Pool(64) as p:         answer = sum(p.map(if_prime, list(range(1000000))))  621 ms \u00b1 10.5 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each) In [ ]:<\/code><\/pre>\n<p>  \u0423 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043d\u043e\u0433\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <i>multiprocessing<\/i>. \u0417\u0430\u0434\u0430\u0447\u0438, \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 (\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0442.\u0434.). \u0415\u0441\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u043c\u0435\u0436\u0434\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  \u0412\u0441\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e:<\/p>\n<ol>\n<li>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/li>\n<li>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f;<\/li>\n<li>\u041f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>multiprocessing.Pool<\/code>. \u0427\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0432 <code>Pool()<\/code>, \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u0447\u0438\u0441\u043b\u0443 \u043f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>with<\/code> \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0443\u0431\u0438\u0442\u044b \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b.<\/li>\n<li>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 Pool \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>map<\/code>. \u0412\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f map \u0431\u0443\u0434\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u0430\u044f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u0438 \u0441\u0430\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/li>\n<\/ol>\n<p>  <i><b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/b>: \u0424\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b.<\/i><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0437\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c <code>multiprocessing<\/code> \u0438 <code>multithreading<\/code>? \u0415\u0441\u043b\u0438 \u0432\u044b \u043a\u043e\u0433\u0434\u0430-\u043b\u0438\u0431\u043e \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e multithreading, \u0432 \u0438\u0442\u043e\u0433\u0435 \u044d\u0444\u0444\u0435\u043a\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0436\u0430\u0441\u043d\u043e! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u0442\u0430\u043a \u0432\u044b\u0448\u043b\u043e.<\/p>\n<p>  \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0441\u0432\u043e\u0435\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u043e\u0439 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, Python \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0432\u0435\u0449\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <b>Global Interpreter Lock (GIL)<\/b>. Python \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0430\u043c \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435, \u043d\u043e <b>GIL<\/b> \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c-\u0432\u044b\u0432\u043e\u0434\u043e\u043c, \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430. \u041e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0434\u0438\u043d URL-\u0430\u0434\u0440\u0435\u0441 \u0438 \u0436\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u044d\u0442\u043e\u0442 \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u0434\u0440\u0443\u0433\u0438\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 URL-\u0430\u0434\u0440\u0435\u0441. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043e\u043d \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a.<\/p>\n<p>  \u0414\u043b\u044f \u0437\u0430\u0434\u0430\u0447, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a\u0436\u0435 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u0430\u043a \u0441\u043e\u0441\u043a\u0438 \u043d\u0430 \u0434\u043e\u0441\u043f\u0435\u0445\u0430\u0445. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c. \u0410 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043a\u0430\u043a \u0440\u0430\u0437 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>multithreading<\/code> \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438 \u044d\u0442\u043e \u00ab\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u00bb, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c <code>multiprocessing<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432, multiprocessing \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442, \u043a\u0430\u043a \u0431\u044b \u0432\u0430\u043c \u044d\u0442\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c\u2026 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 GIL \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c. \u041f\u043e \u0441\u0443\u0442\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u041a\u0430\u043a \u043c\u0438\u043b\u043e \u0441 \u0438\u0445 \u0441\u0442\u043e\u0440\u043e\u043d\u044b!<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0448\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>multiprocessing<\/code> \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c for \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 <code>multithreading<\/code>. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435 \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e, \u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e. \u0418 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e!<\/p>\n<p>  \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e <code>multiprocessing<\/code> \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u0435\u0435, \u0447\u0435\u043c \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 multithreading. (Multiprocessing \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u044b \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u0441\u0432\u043e\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430!) \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e multithreading, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c (\u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043f\u0440\u043e \u0437\u0430\u0434\u0430\u0447\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c-\u0432\u044b\u0432\u043e\u0434\u043e\u043c). \u0410 \u0432\u043e\u0442 \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u0443\u0442\u044b\u043b\u043e\u0447\u043d\u044b\u043c \u0433\u043e\u0440\u043b\u044b\u0448\u043a\u043e\u043c, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f <code>multiprocessing<\/code>. \u041d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0438\u043b\u043e\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0447\u0435\u043c \u0432\u0430\u0448 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u043d\u0435\u0442 \u043f\u0430\u0434\u0430\u0442\u044c. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0431\u043e\u0442\u044b, \u0442\u0430\u0441\u0443\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043c\u0435\u0436\u0434\u0443 \u044f\u0434\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0438\u0434\u0435\u044e \u044f \u0434\u043e\u043d\u0435\u0441. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u043e\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u043f\u0430\u0434\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 16. \u0412\u0441\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u0432\u0441\u0435\u0433\u043e 16 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0434\u0435\u0440.<\/p>\n<h3>\u0413\u043b\u0430\u0432\u0430 4: \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<ul>\n<li>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c-\u0432\u044b\u0432\u043e\u0434\u043e\u043c, <code>multithreading<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/li>\n<li>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c-\u0432\u044b\u0432\u043e\u0434\u043e\u043c, <code>multiprocessing<\/code> \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>multithreading<\/code>.<\/li>\n<li>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 Python GIL \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a.<\/li>\n<li>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>multithreading<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0438\u0437\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/li>\n<li>\u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>multiprocessing<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/li>\n<li>\u0412\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0438 \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0438\u0435!<\/li>\n<\/ul>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 <code>multithreading<\/code> \u0438 <code>multiprocessing<\/code> \u0432 Python. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0434\u0438\u0442\u0435 \u0438 \u043f\u043e\u0431\u0435\u0436\u0434\u0430\u0439\u0442\u0435!<\/p>\n<hr>\n<p>  <a href=\"https:\/\/otus.pw\/V1RB\/\">\u00ab\u041c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 COVID-19 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0433\u0440\u0430\u0444\u043e\u0432 \u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445\u00bb. \u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a.<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/501056\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/501056\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/501056\/\"><b><i>\u0421\u0430\u043b\u044e\u0442, \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435. \u041f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 OTUS \u043e\u0442\u043a\u0440\u044b\u0442 \u043d\u0430\u0431\u043e\u0440 \u043d\u0430 \u043a\u0443\u0440\u0441 <a href=\"https:\/\/otus.pw\/V1RB\/\">\u00abMachine Learning\u00bb<\/a>, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0441 \u043e\u0434\u043d\u0443 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u00ab\u0441\u043a\u0430\u0437\u043e\u0447\u043a\u0443\u00bb. \u041f\u043e\u0435\u0445\u0430\u043b\u0438.<\/i><\/b><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mi\/su\/ev\/misuevluvampqjc3br79pgtgscg.png\">  <\/p>\n<hr>\n<p>  \u0414\u0430\u0432\u043d\u044b\u043c-\u0434\u0430\u0432\u043d\u043e, \u0432 \u0434\u0430\u043b\u0435\u043a\u043e\u0439-\u0434\u0430\u043b\u0435\u043a\u043e\u0439 \u0433\u0430\u043b\u0430\u043a\u0442\u0438\u043a\u0435\u2026<\/p>\n<p>  \u0416\u0438\u043b \u0432 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0434\u0435\u0440\u0435\u0432\u0443\u0448\u043a\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u0438 \u043f\u0443\u0441\u0442\u044b\u043d\u0438 \u043c\u0443\u0434\u0440\u044b\u0439 \u0438 \u043c\u043e\u0433\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a. \u0418 \u0437\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0414\u0430\u043c\u0431\u043b\u0434\u0430\u043b\u044c\u0444. \u041e\u043d \u0431\u044b\u043b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0443\u0434\u0440 \u0438 \u043c\u043e\u0433\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u0435\u043d, \u043d\u043e \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u043b \u043b\u044e\u0434\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0435\u0437\u0436\u0430\u043b\u0438 \u0438\u0437 \u0434\u0430\u043b\u0435\u043a\u0438\u0445 \u0437\u0435\u043c\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u043c\u043e\u0449\u0438 \u0443 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0430. \u041d\u0430\u0448\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u0438\u043d \u043f\u0443\u0442\u043d\u0438\u043a \u043f\u0440\u0438\u043d\u0435\u0441 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0438\u043a\u0443 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0432\u0438\u0442\u043e\u043a. \u041f\u0443\u0442\u043d\u0438\u043a \u043d\u0435 \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u0441\u0432\u0438\u0442\u043a\u0435, \u043e\u043d \u043b\u0438\u0448\u044c \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0438 \u0441\u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u0439\u043d\u044b \u0441\u0432\u0438\u0442\u043a\u0430, \u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0414\u0430\u043c\u0431\u043b\u0434\u0430\u043b\u044c\u0444.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303258","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303258","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=303258"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303258\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}