{"id":174681,"date":"2023-08-03T16:21:05","date_gmt":"2023-08-03T08:21:05","guid":{"rendered":"http:\/\/www.idc.net\/help\/174681\/"},"modified":"2023-08-03T16:21:05","modified_gmt":"2023-08-03T08:21:05","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91python%e6%95%99%e7%a8%8b%ef%bc%9apython-gil%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/174681\/","title":{"rendered":"\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1apython gil\u662f\u4ec0\u4e48"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/oss.py.cn\/pycn\/upload\/image\/672\/789\/706\/1615947482878149.png\" class=\"aligncenter\"><\/p>\n<p><strong>1\u3001\u8bf4\u660e<\/strong><\/p>\n<p>\u662f\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u5728\u6267\u884c\u65f6\u5019\u90fd\u9700\u8981\u5148\u83b7\u53d6GIL\uff0c\u4fdd\u8bc1\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u6267\u884c\u4ee3\u7801\uff0c\u5373\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u4f7f\u7528CPU\uff0c\u4e5f\u5c31\u662f\u8bf4\u591a\u7ebf\u7a0b\u5e76\u4e0d\u662f\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u540c\u65f6\u6267\u884c\u3002<\/p>\n<p><strong>2\u3001\u4ea7\u751f\u539f\u56e0<\/strong><\/p>\n<p>\uff081\uff09Guido van Rossum\uff08\u5409\u591a\u00b7\u8303\u7f57\u82cf\u59c6\uff09\u521b\u5efapython\u65f6\u5c31\u53ea\u8003\u8651\u5230\u5355\u6838cpu\u3002<\/p>\n<p>\uff082\uff09\u89e3\u51b3\u591a\u7ebf\u7a0b\u4e4b\u95f4\u6570\u636e\u5b8c\u6574\u6027\u548c\u72b6\u6001\u540c\u6b65\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u81ea\u7136\u5c31\u662f\u52a0\u9501\u3002 \u4e8e\u662f\u6709\u4e86GIL\u8fd9\u628a\u8d85\u7ea7\u5927\u9501\u3002<\/p>\n<p>\uff083\uff09cpython\u89e3\u6790\u53ea\u5141\u8bb8\u62e5\u6709GIL\u5168\u5c40\u89e3\u6790\u5668\u9501\u624d\u80fd\u8fd0\u884c\u7a0b\u5e8f\u3002<\/p>\n<p>\uff084\uff09\u4fdd\u8bc1\u540c\u4e00\u4e2a\u65f6\u523b\u53ea\u5141\u8bb8\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u4f7f\u7528cpu\u3002<\/p>\n<p>\uff085\uff09\u4ee5\u524d\u5199cpython\u89e3\u6790\u5668\u7684\u65f6\u5019\u5c31\u8003\u8651\u4e00\u4e2acpu\u60c5\u51b5\u3002<\/p>\n<p>\uff086\uff09\u7531\u4e8e\u5927\u91cf\u7684\u7a0b\u5e8f\u5f00\u53d1\u8005\u63a5\u6536\u4e86\u8fd9\u5957\u673a\u5236,\u73b0\u5728\u4ee3\u7801\u91cf\u8d8a\u6765\u8d8a\u591a,\u5df2\u7ecf\u4e0d\u5bb9\u6613\u901a\u8fc7c\u4ee3\u7801\u53bb\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p><strong>3\u3001gil\u9501\u7684\u91ca\u653e\u65f6\u673a<\/strong><\/p>\n<p>\uff081\uff09\u9047\u5230\u50cf i\/o\u64cd\u4f5c\u8fd9\u79cd \u4f1a\u6709\u65f6\u95f4\u7a7a\u95f2\u60c5\u51b5 \u9020\u6210cpu\u95f2\u7f6e\u7684\u60c5\u51b5\u4f1a\u91ca\u653eGil<\/p>\n<p>\uff082\uff09\u4f1a\u6709\u4e00\u4e2a\u4e13\u95e8ticks\u8fdb\u884c\u8ba1\u6570 \u4e00\u65e6ticks\u6570\u503c\u8fbe\u5230100 \u8fd9\u4e2a\u65f6\u5019\u91ca\u653eGil\u9501 \u7ebf\u7a0b\u4e4b\u95f4\u5f00\u59cb\u7ade\u4e89Gil\u9501(\u8bf4\u660e:<\/p>\n<p><span style=\"font-size: 16px\">\uff083\uff09ticks\u8fd9\u4e2a\u6570\u503c\u53ef\u4ee5\u8fdb\u884c\u8bbe\u7f6e\u6765\u5ef6\u957f\u6216\u8005\u7f29\u51cf\u83b7\u5f97Gil\u9501\u7684\u7ebf\u7a0b\u4f7f\u7528cpu\u7684\u65f6\u95f4)<\/span><\/p>\n<p><span style=\"font-size: 16px\">\u4ee5\u4e0a\u5c31\u662fpython gil\u7684\u4ecb\u7ecd\uff0c\u5927\u5bb6\u5728\u4e86\u89e3\u57fa\u672c\u7684\u7528\u6cd5\u540e\uff0c\u53ef\u4ee5\u53bb\u627e\u4e00\u4e9bgil\u7684\u5b9e\u4f8b\u8fdb\u884c\u7ec3\u4e60\u3002<span style=\"font-size: 14px\">\u66f4\u591aPython\u5b66\u4e60\u6307\u8def\uff1a<\/span><\/span><span style=\"font-size: 16px\">\u540e\u6d6a\u4e91python\u6559\u7a0b<\/span><\/p>\n<p><span><\/span> <\/p>\n<p><span style=\"font-size: 14px\">\uff08\u63a8\u8350\u64cd\u4f5c\u7cfb\u7edf\uff1awindows7\u7cfb\u7edf\u3001Python 3.9.1\uff0cDELL G3\u7535\u8111\u3002\uff09<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u8bf4\u660e \u662f\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u5728\u6267\u884c\u65f6\u5019\u90fd\u9700\u8981\u5148\u83b7\u53d6GIL\uff0c\u4fdd\u8bc1\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u6267\u884c\u4ee3\u7801\uff0c\u5373\u540c\u4e00\u65f6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":174682,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182397],"tags":[],"class_list":["post-174681","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/174681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=174681"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/174681\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/174682"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=174681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=174681"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=174681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}