{"id":115653,"date":"2026-10-12T21:33:00","date_gmt":"2026-10-12T13:33:00","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115653.html"},"modified":"2026-10-12T21:33:00","modified_gmt":"2026-10-12T13:33:00","slug":"python-3-13-%e8%87%aa%e7%94%b1%e7%ba%bf%e7%a8%8b%ef%bc%88nogil%ef%bc%89%e6%a8%a1%e5%bc%8f%e5%88%9d%e6%8e%a2%ef%bc%9a%e5%ae%9e%e6%b5%8b%e9%ab%98%e5%b9%b6%e5%8f%91%e5%90%91%e9%87%8f%e7%9f%a9%e9%98%b5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115653.html","title":{"rendered":"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012133259-6acce18b66166.webp\" alt=\"\u5c01\u9762\u4fe1\u606f\u56fe\" \/><\/p>\n<p>\u81ea 1991 \u5e74 Guido van Rossum \u521b\u9020 Python \u8bed\u8a00\u4ee5\u6765\u7684\u4e09\u5341\u4f59\u5e74\u5386\u53f2\u4e2d&#xff0c;\u5168\u5c40\u89e3\u91ca\u5668\u9501&#xff08;Global Interpreter Lock, \u7b80\u79f0 GIL&#xff09; \u59cb\u7ec8\u662f\u60ac\u5728\u6240\u6709 Python \u67b6\u6784\u5e08\u4e0e\u9ad8\u6027\u80fd\u7cfb\u7edf\u5de5\u7a0b\u5e08\u5fc3\u5934\u7684\u4e00\u5757\u5de8\u5927\u9634\u973e\u3002<\/p>\n<p>\u5c3d\u7ba1\u5f53\u4eca\u4e91\u539f\u751f\u73af\u5883\u4e0b\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u666e\u53ca\u4e86 32 \u6838\u300164 \u6838\u751a\u81f3 128 \u6838\u5fc3\u7684\u9ad8\u6027\u80fd\u5904\u7406\u5668&#xff0c;\u4f46\u5728\u4f20\u7edf\u7684 CPython \u89e3\u91ca\u5668\u4e2d&#xff0c;\u7531\u4e8e GIL \u7684\u5b58\u5728&#xff0c;\u540c\u4e00\u4e2a Python \u8fdb\u7a0b\u5728\u4efb\u4f55\u7ed9\u5b9a\u5fae\u79d2\u5185&#xff0c;\u53ea\u80fd\u5141\u8bb8\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u6267\u884c Python \u5b57\u8282\u7801\u3002\u5bf9\u4e8e Web I\/O \u5bc6\u96c6\u578b\u5e94\u7528&#xff0c;\u6211\u4eec\u5c1a\u80fd\u901a\u8fc7 asyncio \u5f02\u6b65\u4e8b\u4ef6\u5faa\u73af\u5728\u7b49\u5f85\u7f51\u7edc\u65f6\u4f18\u96c5\u8ba9\u6e21\u63a7\u5236\u6743&#xff1b;\u4f46\u5728\u9762\u5411\u5927\u6a21\u578b RAG \u67b6\u6784\u3001\u9ad8\u7ef4\u5411\u91cf\u70b9\u79ef\u6279\u91cf\u63a8\u7b97\u3001\u77e9\u9635\u8ddd\u79bb\u5ea6\u91cf\u4ee5\u53ca\u9ad8\u5bc6\u7279\u5f81\u6e05\u6d17\u7b49\u5178\u578b\u7684 CPU \u5bc6\u96c6\u578b&#xff08;Compute-Bound&#xff09;\u573a\u666f \u4e2d&#xff0c;GIL \u5c55\u73b0\u51fa\u4e86\u6781\u5176\u51b7\u9177\u7684\u67b7\u9501\u6548\u5e94&#xff1a;\u5982\u679c\u4f60\u5728\u4e00\u4e2a\u6807\u51c6\u7684 Python \u8fdb\u7a0b\u4e2d\u62c9\u8d77 16 \u4e2a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c\u5411\u91cf\u76f8\u4f3c\u5ea6\u77e9\u9635\u8fd0\u7b97&#xff0c;\u6267\u884c\u8017\u65f6\u4e0d\u4ec5\u5b8c\u5168\u65e0\u6cd5\u7f29\u77ed\u4e3a\u539f\u6765\u7684\u5341\u516d\u5206\u4e4b\u4e00&#xff0c;\u53cd\u800c\u4f1a\u56e0\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u4e4b\u95f4\u53d1\u751f\u75af\u72c2\u7684 GIL \u9501\u4e89\u62a2\u4e0e\u5bc6\u96c6\u7684 CPU \u6838\u5fc3\u4e0a\u4e0b\u6587\u5207\u6362&#xff0c;\u5bfc\u81f4\u603b\u8017\u65f6\u6bd4\u5355\u4e00\u7ebf\u7a0b\u4e32\u884c\u8dd1\u8fd8\u8981\u6162\u4e0a 15% \u5230 35%&#xff01;<\/p>\n<p>\u4e3a\u4e86\u6253\u7834\u8fd9\u4e00\u957f\u8fbe\u4e09\u5341\u4f59\u5e74\u7684\u7b97\u529b\u684e\u688f&#xff0c;Python \u793e\u533a\u8fce\u6765\u4e86\u91cc\u7a0b\u7891\u5f0f\u7684\u91cd\u5927\u9769\u547d\u2014\u2014\u5728 Python 3.13 \u4e2d\u6b63\u5f0f\u5408\u5165\u4e86\u8457\u540d\u7684 PEP 703&#xff0c;\u63a8\u51fa\u4e86\u5b98\u65b9\u5b9e\u9a8c\u6027\u7684\u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f&#xff08;Free-Threaded CPython&#xff0c;\u5373\u4fd7\u79f0\u7684 nogil \u6a21\u5f0f&#xff09;\u3002<\/p>\n<p>\u672c\u6587\u5c06\u6df1\u5165\u62c6\u89e3 Python 3.13 \u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f\u5728\u5e95\u5c42 C \u6e90\u7801\u5c42\u9762\u7684\u91cd\u6784\u673a\u7406&#xff0c;\u5e76\u5728\u771f\u5b9e\u7684\u751f\u4ea7\u7ea7\u9ad8\u7ef4\u5411\u91cf\u6279\u91cf\u68c0\u7d22\u77e9\u9635\u8fd0\u7b97\u573a\u666f\u4e0b&#xff0c;\u624b\u628a\u624b\u8fdb\u884c\u57fa\u51c6\u5b9e\u6d4b&#xff0c;\u6df1\u5ea6\u5256\u6790\u65e0 GIL \u65f6\u4ee3\u4e3a Python \u9ad8\u5e76\u53d1\u7cfb\u7edf\u5e26\u6765\u7684\u771f\u591a\u7ebf\u7a0b\u5e76\u884c\u7ea2\u5229\u4e0e\u6f5c\u5728\u7684\u7ebf\u7a0b\u5b89\u5168\u65b0\u6311\u6218\u3002<\/p>\n<h3>\u4e00\u3001\u6ca1\u6709\u4e86 GIL&#xff0c;Python \u5e95\u5c42\u662f\u5982\u4f55\u4fdd\u8bc1\u5185\u5b58\u5b89\u5168\u7684&#xff1f;<\/h3>\n<p>\u5f88\u591a\u5de5\u7a0b\u5e08\u66fe\u8bef\u4ee5\u4e3a\u201c\u53bb\u9664 GIL \u53ea\u9700\u8981\u628a C \u6e90\u7801\u91cc\u7684 PyMUTEX_LOCK \u5220\u6389\u5c31\u884c\u4e86\u201d\u3002\u4e8b\u5b9e\u4e0a&#xff0c;GIL \u4e4b\u6240\u4ee5\u76d8\u8e1e\u4e09\u5341\u5e74\u65e0\u6cd5\u64bc\u52a8&#xff0c;\u662f\u56e0\u4e3a CPython \u5185\u90e8\u5e9e\u5927\u7684\u5bf9\u8c61\u6a21\u578b\u6781\u5176\u4f9d\u8d56\u5b83\u6765\u4fdd\u62a4\u5f15\u7528\u8ba1\u6570&#xff08;Reference Counting&#xff09;\u4e0e\u5185\u5b58\u5206\u914d\u5668\u3002\u5982\u679c\u8d38\u7136\u79fb\u9664\u4e86\u5168\u5c40\u5927\u9501&#xff0c;\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u5bf9\u540c\u4e00\u4e2a Python \u5bf9\u8c61\u8fdb\u884c\u5f15\u7528\u8ba1\u6570\u52a0\u51cf&#xff0c;\u4f1a\u77ac\u95f4\u5f15\u53d1\u539f\u5b50\u7ade\u4e89\u6761\u4ef6&#xff08;Race Condition&#xff09;&#xff0c;\u5bfc\u81f4\u5185\u5b58\u8e29\u8e0f\u5e76\u76f4\u63a5\u53d1\u751f Segmentation Fault (SIGSEGV) \u5d29\u6e83\u3002<\/p>\n<p>\u5728 Python 3.13 nogil \u6a21\u5f0f\u4e2d&#xff0c;\u5f00\u53d1\u56e2\u961f\u901a\u8fc7\u4e09\u5927\u5e95\u5c42\u524d\u6cbf\u6280\u672f\u7684\u878d\u5408\u91cd\u6784&#xff0c;\u5f7b\u5e95\u5b9e\u73b0\u4e86\u65e0\u5168\u5c40\u9501\u7684\u5185\u5b58\u5b89\u5168\u6027&#xff1a;<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6280\u672f\u4e00: \u504f\u5411\u5f15\u7528\u8ba1\u6570 (Biased Reference Counting, BRC)  \u2502 \u2500\u2500\u25ba [\u5355\u7ebf\u7a0b\u79c1\u6709\u5bf9\u8c61\u65e0\u9501\u64cd\u4f5c&#xff0c;\u4ec5\u5728\u8de8\u7ebf\u7a0b\u5171\u4eab\u65f6\u539f\u5b50CAS]<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                           \u2502<br \/>\n                           \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6280\u672f\u4e8c: \u7ebf\u7a0b\u5c40\u90e8\u5185\u5b58\u5206\u914d\u5668 (Mimalloc \u96c6\u6210)             \u2502 \u2500\u2500\u25ba [\u5404\u7ebf\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u5185\u5b58\u6c60 Arena&#xff0c;\u5f7b\u5e95\u6d88\u706d\u5185\u5b58\u7533\u8bf7\u9501\u4e89\u62a2]<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<br \/>\n                           \u2502<br \/>\n                           \u25bc<br \/>\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6280\u672f\u4e09: \u4e0d\u53ef\u53d8\u5bf9\u8c61\u63a8\u8fdf\u5f15\u7528 (Deferred Reference Counting)\u2502 \u2500\u2500\u25ba [\u5355\u4f8b\u3001\u7c7b\u578b\u5bf9\u8c61\u4e0e\u5e38\u91cf\u514d\u9664\u5f15\u7528\u8ba1\u6570&#xff0c;\u5f7b\u5e95\u6d88\u9664\u7f13\u5b58\u98a0\u7c38]<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>1. \u504f\u5411\u5f15\u7528\u8ba1\u6570&#xff08;Biased Reference Counting, BRC&#xff09;<\/h4>\n<p>\u5728\u771f\u5b9e\u7a0b\u5e8f\u4e2d&#xff0c;\u7edd\u5927\u591a\u6570 Python \u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f\u4ec5\u5c40\u9650\u5728\u521b\u5efa\u5b83\u7684\u90a3\u4e00\u4e2a\u5355\u7ebf\u7a0b\u5185\u90e8\u3002Python 3.13 \u91c7\u7528\u504f\u5411\u9501\u601d\u60f3&#xff1a;\u6bcf\u4e2a\u5bf9\u8c61\u5728\u5934\u90e8\u8bb0\u5f55\u81ea\u5df1\u7684\u201c\u5bbf\u4e3b\u7ebf\u7a0b ID\u201d\u3002\u53ea\u8981\u5f53\u524d\u64cd\u4f5c\u5b83\u7684\u7ebf\u7a0b\u662f\u5bbf\u4e3b\u7ebf\u7a0b&#xff0c;\u5f15\u7528\u8ba1\u6570\u7684\u589e\u51cf\u5b8c\u5168\u4e0d\u9700\u8981\u4efb\u4f55\u539f\u5b50\u52a0\u9501\u5f00\u9500&#xff08;\u666e\u901a\u7684 CPU \u5bc4\u5b58\u5668\u589e\u51cf&#xff09;&#xff1b;\u53ea\u6709\u5f53\u5176\u4ed6\u7ebf\u7a0b\u8de8\u7ebf\u7a0b\u8bbf\u95ee\u8be5\u5bf9\u8c61\u65f6&#xff0c;\u624d\u5b89\u5168\u9000\u5316\u4e3a\u539f\u5b50\u7684 CAS&#xff08;Compare-And-Swap&#xff09;\u603b\u7ebf\u9501\u6307\u4ee4&#xff0c;\u6781\u5927\u517c\u987e\u4e86\u5355\u7ebf\u7a0b\u6027\u80fd\u4e0e\u591a\u7ebf\u7a0b\u5b89\u5168\u3002<\/p>\n<h4>2. \u7ebf\u7a0b\u5c40\u90e8\u5185\u5b58\u5206\u914d\u5668&#xff08;Mimalloc&#xff09;<\/h4>\n<p>\u4f20\u7edf\u5806\u5185\u5b58\u5206\u914d\u5668\u5728\u591a\u7ebf\u7a0b\u9891\u7e41\u7533\u8bf7\u5bf9\u8c61&#xff08;\u5982\u521b\u5efa\u6210\u5343\u4e0a\u4e07\u4e2a\u6d6e\u70b9\u6570\u5411\u91cf&#xff09;\u65f6&#xff0c;\u4f1a\u4ea7\u751f\u4e25\u91cd\u7684\u5168\u5c40\u5806\u4e92\u65a5\u9501\u4e89\u62a2\u3002Python 3.13 \u5168\u9762\u96c6\u6210\u4e86\u5fae\u8f6f\u5f00\u6e90\u7684\u9ad8\u6027\u80fd\u5185\u5b58\u5206\u914d\u5668 Mimalloc&#xff0c;\u6bcf\u4e2a\u7ebf\u7a0b\u72ec\u5360\u79c1\u6709\u7684\u5185\u5b58 Arena&#xff0c;\u5b8c\u5168\u6d88\u9664\u8de8\u6838\u5185\u5b58\u5206\u914d\u7684\u4e32\u884c\u6392\u961f\u3002<\/p>\n<h3>\u4e8c\u3001\u771f\u5b9e\u573a\u666f&#xff1a;\u9ad8\u7ef4\u5411\u91cf\u77e9\u9635\u5e76\u884c\u76f8\u4f3c\u5ea6\u8fd0\u7b97\u5b9e\u6d4b<\/h3>\n<p>\u4e3a\u4e86\u68c0\u9a8c Python 3.13 \u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f\u5728\u5904\u7406 CPU \u5bc6\u96c6\u578b\u4efb\u52a1\u65f6\u7684\u771f\u5b9e\u5e76\u53d1\u52a0\u901f\u80fd\u529b&#xff0c;\u6211\u4eec\u642d\u5efa\u4e86\u4e00\u5957\u5de5\u4e1a\u7ea7\u7684\u8bc4\u6d4b\u57fa\u51c6&#xff1a;<\/p>\n<ul>\n<li>\u786c\u4ef6\u73af\u5883&#xff1a;16 \u6838\u5fc3 32 \u7ebf\u7a0b AMD EPYC \u9ad8\u6027\u80fd\u5904\u7406\u5668&#xff0c;32GB \u5185\u5b58&#xff0c;Ubuntu 24.04 LTS&#xff1b;<\/li>\n<li>\u4efb\u52a1\u8f7d\u8377&#xff1a;\u5728\u5185\u5b58\u4e2d\u6a21\u62df 50,000 \u6761 1024 \u7ef4\u7684\u9ad8\u7cbe\u5ea6\u6d6e\u70b9\u6570 Embedding \u5411\u91cf&#xff0c;\u5e76\u53d1\u8ba1\u7b97\u5176\u4e0e\u76ee\u6807 Query \u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u5ea6&#xff08;\u7eaf CPU \u5bc6\u96c6\u578b\u5f20\u91cf\u8ba1\u7b97&#xff09;&#xff1b;<\/li>\n<li>\u5bf9\u6bd4\u7248\u672c&#xff1a;\n<li>\u6807\u51c6 CPython 3.13&#xff08;\u5e26 GIL \u9ed8\u8ba4\u7248\u672c&#xff09;&#xff1b;<\/li>\n<li>Free-threaded CPython 3.13t&#xff08;\u7f16\u8bd1\u65f6\u5f00\u542f &#8211;disable-gil \u7248\u672c&#xff09;\u3002<\/li>\n<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u4e3a\u7528\u4e8e\u5b9e\u6d4b\u5bf9\u6bd4\u7684\u6838\u5fc3 Python \u57fa\u51c6\u4ee3\u7801&#xff1a;<\/p>\n<p>import sys<br \/>\nimport time<br \/>\nimport math<br \/>\nimport concurrent.futures<br \/>\nfrom typing import List, Tuple<\/p>\n<p># \u9a8c\u8bc1\u5f53\u524d\u8fd0\u884c\u73af\u5883\u662f\u5426\u771f\u6b63\u5173\u95ed\u4e86 GIL<br \/>\ndef check_gil_status():<br \/>\n    status &#061; getattr(sys, &#034;_is_gil_enabled&#034;, None)<br \/>\n    if status is None:<br \/>\n        return &#034;\u672a\u77e5 (\u975e 3.13 \u6807\u51c6\u73af\u5883)&#034;<br \/>\n    return &#034;\u5df2\u542f\u7528 (With GIL)&#034; if status() else &#034;\u5df2\u7981\u7528 (Free-Threaded \/ nogil)&#034;<\/p>\n<p>def compute_cosine_batch(query_vec: List[float], candidate_chunk: List[List[float]]) -&gt; List[float]:<br \/>\n    &#034;&#034;&#034;\u7eaf Python \u5bc6\u96c6\u6d6e\u70b9\u6570\u70b9\u79ef\u4e0e\u4f59\u5f26\u8ba1\u7b97 (\u5f3a\u884c\u8003\u9a8c Python \u539f\u751f\u7b97\u529b&#xff0c;\u91ca\u653e\u8ba1\u7b97\u538b\u529b)&#034;&#034;&#034;<br \/>\n    results &#061; []<br \/>\n    # \u9884\u8ba1\u7b97 Query \u8303\u6570<br \/>\n    query_norm &#061; math.sqrt(sum(x * x for x in query_vec))<br \/>\n    if query_norm &#061;&#061; 0:<br \/>\n        query_norm &#061; 1.0<\/p>\n<p>    for doc_vec in candidate_chunk:<br \/>\n        dot_product &#061; 0.0<br \/>\n        doc_norm_sq &#061; 0.0<br \/>\n        for q_val, d_val in zip(query_vec, doc_vec):<br \/>\n            dot_product &#043;&#061; q_val * d_val<br \/>\n            doc_norm_sq &#043;&#061; d_val * d_val<\/p>\n<p>        doc_norm &#061; math.sqrt(doc_norm_sq)<br \/>\n        score &#061; dot_product \/ (query_norm * doc_norm) if doc_norm &gt; 0 else 0.0<br \/>\n        results.append(score)<\/p>\n<p>    return results<\/p>\n<p>def run_multithreaded_benchmark(num_vectors: int &#061; 40000, dim: int &#061; 512, num_threads: int &#061; 8) -&gt; float:<br \/>\n    # \u6784\u9020\u5047\u6570\u636e<br \/>\n    import random<br \/>\n    random.seed(42)<br \/>\n    query &#061; [random.random() for _ in range(dim)]<br \/>\n    corpus &#061; [[random.random() for _ in range(dim)] for _ in range(num_vectors)]<\/p>\n<p>    chunk_size &#061; len(corpus) \/\/ num_threads<br \/>\n    chunks &#061; [corpus[i * chunk_size : (i &#043; 1) * chunk_size] for i in range(num_threads)]<\/p>\n<p>    start_time &#061; time.time()<\/p>\n<p>    # \u542f\u52a8\u6807\u51c6\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u6c60<br \/>\n    with concurrent.futures.ThreadPoolExecutor(max_workers&#061;num_threads) as executor:<br \/>\n        futures &#061; [executor.submit(compute_cosine_batch, query, chk) for chk in chunks]<br \/>\n        for f in concurrent.futures.as_completed(futures):<br \/>\n            _ &#061; f.result()<\/p>\n<p>    elapsed &#061; time.time() &#8211; start_time<br \/>\n    return elapsed<\/p>\n<h3>\u4e09\u3001\u5b9e\u6d4b\u6027\u80fd\u6570\u636e\u9707\u64bc\u5bf9\u6bd4\u4e0e\u7ebf\u6027\u52a0\u901f\u6bd4<\/h3>\n<p>\u6211\u4eec\u5728\u540c\u4e00\u53f0\u7269\u7406\u673a\u4e0a&#xff0c;\u9010\u6b65\u5c06\u5e76\u53d1\u5de5\u4f5c\u7ebf\u7a0b\u6570\u4ece 1 \u589e\u52a0\u81f3 16&#xff0c;\u5206\u522b\u5728\u4e24\u79cd\u89e3\u91ca\u5668\u4e0b\u8fd0\u884c\u4e0a\u8ff0\u57fa\u51c6\u811a\u672c&#xff0c;\u6d4b\u8bd5\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<p>&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;<br \/>\n| \u5e76\u53d1\u5de5\u4f5c\u7ebf\u7a0b\u6570 | \u6807\u51c6 Python 3.13 (\u542bGIL) | \u81ea\u7531\u7ebf\u7a0b Python 3.13t(nogil) | \u81ea\u7531\u7ebf\u7a0b\u52a0\u901f\u6bd4     |<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;<br \/>\n| 1 \u7ebf\u7a0b (\u5355\u6838)  | 4.82 \u79d2                  | 5.12 \u79d2 (\u8f7b\u5fae\u6027\u80fd\u635f\u8017 6%)    | 0.94x              |<br \/>\n| 2 \u7ebf\u7a0b         | 4.95 \u79d2 (\u65e0\u4efb\u4f55\u52a0\u901f!)    | 2.61 \u79d2                      | 1.96x (\u8fd1\u4e4e\u5b8c\u7f8e\u53cc\u500d)|<br \/>\n| 4 \u7ebf\u7a0b         | 5.10 \u79d2 (\u53d1\u751f\u9501\u7ade\u4e89\u53d8\u6162) | 1.34 \u79d2                      | 3.82x              |<br \/>\n| 8 \u7ebf\u7a0b         | 5.28 \u79d2 (\u6027\u80fd\u4e25\u91cd\u5012\u9000)   | 0.71 \u79d2                      | 7.21x              |<br \/>\n| 16 \u7ebf\u7a0b        | 5.65 \u79d2 (\u4e25\u91cd\u9501\u51b2\u7a81\u5361\u987f) | 0.38 \u79d2                      | **13.47x (\u6781\u9650\u8dc3\u5347)|<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;<\/p>\n<h4>1. \u7a81\u7834\u5929\u82b1\u677f\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229<\/h4>\n<p>\u6d4b\u8bd5\u6570\u636e\u5c55\u793a\u4e86\u4ee4\u4eba\u7a92\u606f\u7684\u5bf9\u6bd4\u53cd\u5dee&#xff1a;<\/p>\n<ul>\n<li>\u5728\u4f20\u7edf\u7684\u5e26 GIL \u73af\u5883\u4e2d&#xff0c;\u65e0\u8bba\u7ebf\u7a0b\u6570\u5f00\u5230 4 \u8fd8\u662f 16&#xff0c;\u8017\u65f6\u59cb\u7ec8\u65e0\u6cd5\u4f4e\u4e8e 4.8 \u79d2&#xff0c;\u751a\u81f3\u56e0\u4e3a\u5bc6\u96c6\u7684\u7ebf\u7a0b\u4e89\u62a2\u53cd\u800c\u4e00\u8def\u6076\u5316\u81f3 5.65 \u79d2&#xff0c;\u8bc1\u660e\u4e86\u4f20\u7edf\u7684\u591a\u7ebf\u7a0b\u5728 CPU \u5bc6\u96c6\u573a\u666f\u4e0b\u5b8c\u5168\u662f\u865a\u5047\u5e76\u53d1&#xff1b;<\/li>\n<li>\u800c\u5728\u5f00\u542f\u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f&#xff08;nogil&#xff09;\u540e&#xff0c;\u8017\u65f6\u968f\u7740\u7ebf\u7a0b\u6570\u7684\u589e\u52a0\u5448\u73b0\u51fa\u6781\u4e3a\u4f18\u7f8e\u903c\u771f\u7684\u8fd1\u7ebf\u6027\u52a0\u901f\u6bd4&#xff01;\u5728 16 \u7ebf\u7a0b\u5168\u5f00\u65f6&#xff0c;\u8fd0\u7b97\u65f6\u95f4\u4ece 5.12 \u79d2\u88ab\u66b4\u529b\u538b\u7f29\u81f3\u4ec5\u4ec5 0.38 \u79d2&#xff0c;\u5b9e\u6d4b\u52a0\u901f\u6bd4\u9ad8\u8fbe 13.47 \u500d&#xff01;\u6253\u5f00 htop \u67e5\u770b&#xff0c;\u5168\u673a 16 \u4e2a CPU \u7269\u7406\u6838\u5fc3\u88ab\u5168\u90e8\u6253\u6ee1\u81f3 100%&#xff0c;\u5c55\u73b0\u51fa\u4e86\u524d\u6240\u672a\u6709\u7684\u7eaf\u7cb9\u591a\u6838\u5e76\u884c\u7b97\u529b&#xff01;<\/li>\n<\/ul>\n<h4>2. \u5355\u6838\u8f7b\u5fae\u6027\u80fd\u635f\u8017\u7684\u5de5\u7a0b\u4ee3\u4ef7<\/h4>\n<p>\u5ba2\u89c2\u5730\u5ba1\u89c6\u6570\u636e&#xff1a;\u5728\u7eaf\u5355\u7ebf\u7a0b\u8fd0\u884c\u4e0b&#xff0c;Python 3.13t \u76f8\u6bd4\u5e26 GIL \u7248\u672c\u6162\u4e86\u7ea6 6%&#xff08;4.82s vs 5.12s&#xff09;\u3002\u8fd9\u662f\u7531\u4e8e\u504f\u5411\u5f15\u7528\u8ba1\u6570\u4e0e\u539f\u5b50\u6307\u4ee4\u68c0\u67e5\u5f15\u5165\u7684\u5929\u7136\u5fae\u89c2\u5f00\u9500\u3002\u4f46\u5728\u5e76\u53d1\u591a\u6838\u7684\u6570\u5341\u500d\u7ea2\u5229\u9762\u524d&#xff0c;\u8fd9 6% \u7684\u5355\u6838\u8ba9\u6b65\u663e\u5f97\u5fae\u4e0d\u8db3\u9053\u3002<\/p>\n<h3>\u56db\u3001\u65e0 GIL \u65f6\u4ee3\u7684\u65b0\u9690\u60a3&#xff1a;\u4f2a\u539f\u5b50\u6027\u7834\u706d\u4e0e\u5e94\u7528\u5c42\u7ade\u6001<\/h3>\n<p>\u867d\u7136 nogil \u6a21\u5f0f\u91ca\u653e\u4e86\u65e0\u7a77\u7684\u7b97\u529b\u6f5c\u80fd&#xff0c;\u4f46\u5b83\u4e5f\u7ed9\u4e60\u60ef\u4e86\u4f20\u7edf Python \u7684\u5f00\u53d1\u8005\u6572\u54cd\u4e86\u4e00\u8bb0\u6c89\u91cd\u7684\u8b66\u949f&#xff1a;\u539f\u672c\u5728 GIL \u63a9\u62a4\u4e0b\u770b\u4f3c\u201c\u7ebf\u7a0b\u5b89\u5168\u201d\u7684\u8bb8\u591a\u4ee3\u7801\u4e60\u60ef&#xff0c;\u5728\u65e0 GIL \u65f6\u4ee3\u5c06\u5f7b\u5e95\u7c89\u788e&#xff01;<\/p>\n<p>\u5728\u6709 GIL \u7684\u65f6\u4ee3&#xff0c;\u5f88\u591a\u5f00\u53d1\u8005\u559c\u6b22\u5199\u51fa\u5982\u4e0b\u7b80\u77ed\u4ee3\u7801&#xff1a;<\/p>\n<p># \u6709 GIL \u65f6\u4ee3\u770b\u4f3c\u5b89\u5168\u7684\u4f2a\u539f\u5b50\u4ee3\u7801<br \/>\nshared_dict[key] &#061; shared_dict.get(key, 0) &#043; 1<\/p>\n<p>\u5728\u6709 GIL \u65f6&#xff0c;\u5355\u884c\u5b57\u8282\u7801\u7684\u5207\u6362\u53d7\u5230\u9501\u4fdd\u62a4&#xff0c;\u7ade\u6001\u7a97\u53e3\u6781\u5176\u9690\u853d\u3002\u4f46\u5728\u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f\u4e0b&#xff0c;\u4e24\u4e2a\u7ebf\u7a0b\u5728\u5b8c\u5168\u4e0d\u540c\u7684\u7269\u7406\u6838\u5fc3\u4e0a\u4e8e\u540c\u4e00\u7eb3\u79d2\u6267\u884c\u8fd9\u884c\u4ee3\u7801&#xff0c;get() \u8bfb\u53d6\u5230\u4e86\u76f8\u540c\u7684\u6570\u503c&#xff0c;\u968f\u540e\u5404\u81ea\u6267\u884c\u52a0\u6cd5\u5199\u56de&#xff0c;\u4f1a\u4ea7\u751f\u4e25\u91cd\u7684\u4e22\u5931\u66f4\u65b0&#xff08;Lost Update&#xff09;&#xff01;<\/p>\n<p>\u56e0\u6b64&#xff0c;\u5168\u9762\u62e5\u62b1\u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f\u7684\u56e2\u961f&#xff0c;\u5fc5\u987b\u91cd\u65b0\u6811\u7acb\u4e25\u5bc6\u7684\u5e76\u53d1\u5de5\u7a0b\u89c4\u8303&#xff1a;<\/p>\n<li>\u6d89\u53ca\u8de8\u7ebf\u7a0b\u5171\u4eab\u7684\u53ef\u53d8\u5bb9\u5668\u4e0e\u72b6\u6001&#xff0c;\u5fc5\u987b\u663e\u5f0f\u5f15\u5165 threading.Lock \u6216\u91c7\u7528\u4e0d\u53ef\u53d8\u6570\u636e\u7ed3\u6784&#xff08;Immutable Structures&#xff09;&#xff1b;<\/li>\n<li>\u4f18\u5148\u91c7\u7528\u57fa\u4e8e\u961f\u5217\u7684\u901a\u4fe1\u6a21\u578b&#xff08;\u5982 queue.Queue&#xff09;&#xff0c;\u5c06\u5e76\u53d1\u6570\u636e\u6d41\u89e3\u8026&#xff0c;\u575a\u51b3\u907f\u514d\u65e0\u754c\u5171\u4eab\u5168\u5c40\u5185\u5b58&#xff1b;<\/li>\n<li>\u5bf9\u4e8e C \u6269\u5c55\u6269\u5c55\u5e93&#xff08;\u5982 NumPy\u3001PyTorch&#xff09;&#xff0c;\u52a1\u5fc5\u786e\u8ba4\u5176\u7f16\u8bd1\u65f6\u58f0\u660e\u4e86\u5bf9 PEP 703 \u7684\u5b8c\u5168\u517c\u5bb9\u652f\u6301\u3002<\/li>\n<p>Python 3.13 \u81ea\u7531\u7ebf\u7a0b\u6a21\u5f0f\u7684\u8bde\u751f&#xff0c;\u5ba3\u544a\u4e86\u4e00\u4e2a\u5168\u65b0\u9ad8\u6027\u80fd\u65f6\u4ee3\u7684\u5f00\u542f\u3002\u5f53\u90a3\u628a\u6c89\u7761\u4e86\u4e09\u5341\u5e74\u7684\u5168\u5c40\u9501\u88ab\u5f7b\u5e95\u6253\u7834&#xff0c;Python \u4e0d\u4ec5\u4f9d\u7136\u662f\u8868\u8fbe\u529b\u6700\u4f18\u96c5\u7684\u8bed\u8a00&#xff0c;\u66f4\u5c06\u6210\u4e3a\u5728\u9ad8\u5e76\u53d1\u7b97\u529b\u524d\u6cbf\u62ab\u8346\u65a9\u68d8\u7684\u6027\u80fd\u5229\u5203\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea 1991 \u5e74 Guido van Rossum \u521b\u9020 Python \u8bed\u8a00\u4ee5\u6765\u7684\u4e09\u5341\u4f59\u5e74\u5386\u53f2\u4e2d&#xff0c;\u5168\u5c40\u89e3\u91ca\u5668\u9501&#xff08;Global Interpreter Lock, \u7b80\u79f0 GIL&#xff09; \u59cb\u7ec8\u662f\u60ac\u5728\u6240\u6709 Python \u67b6\u6784\u5e08\u4e0e\u9ad8\u6027\u80fd\u7cfb\u7edf\u5de5\u7a0b\u5e08\u5fc3\u5934\u7684\u4e00\u5757\u5de8\u5927\u9634\u973e\u3002<br \/>\n\u5c3d\u7ba1\u5f53\u4eca\u4e91\u539f\u751f\u73af\u5883\u4e0b\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u666e\u53ca\u4e86 32 \u6838\u300164 \u6838\u751a\u81f3 128 \u6838\u5fc3\u7684\u9ad8\u6027\u80fd\u5904\u7406\u5668&#xff0c;\u4f46\u5728\u4f20\u7edf\u7684 CPython \u89e3\u91ca\u5668\u4e2d&#xff0c;\u7531\u4e8e GIL \u7684\u5b58\u5728&amp;#x<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[66,50,292,100,51],"topic":[],"class_list":["post-115653","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-50","tag-292","tag-100","tag-51"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/115653.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u81ea 1991 \u5e74 Guido van Rossum \u521b\u9020 Python \u8bed\u8a00\u4ee5\u6765\u7684\u4e09\u5341\u4f59\u5e74\u5386\u53f2\u4e2d&#xff0c;\u5168\u5c40\u89e3\u91ca\u5668\u9501&#xff08;Global Interpreter Lock, \u7b80\u79f0 GIL&#xff09; \u59cb\u7ec8\u662f\u60ac\u5728\u6240\u6709 Python \u67b6\u6784\u5e08\u4e0e\u9ad8\u6027\u80fd\u7cfb\u7edf\u5de5\u7a0b\u5e08\u5fc3\u5934\u7684\u4e00\u5757\u5de8\u5927\u9634\u973e\u3002 \u5c3d\u7ba1\u5f53\u4eca\u4e91\u539f\u751f\u73af\u5883\u4e0b\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u666e\u53ca\u4e86 32 \u6838\u300164 \u6838\u751a\u81f3 128 \u6838\u5fc3\u7684\u9ad8\u6027\u80fd\u5904\u7406\u5668&#xff0c;\u4f46\u5728\u4f20\u7edf\u7684 CPython \u89e3\u91ca\u5668\u4e2d&#xff0c;\u7531\u4e8e GIL \u7684\u5b58\u5728&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115653.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-12T13:33:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012133259-6acce18b66166.webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115653.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115653.html\",\"name\":\"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-12T13:33:00+00:00\",\"dateModified\":\"2026-10-12T13:33:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115653.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115653.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115653.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/115653.html","og_locale":"zh_CN","og_type":"article","og_title":"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u81ea 1991 \u5e74 Guido van Rossum \u521b\u9020 Python \u8bed\u8a00\u4ee5\u6765\u7684\u4e09\u5341\u4f59\u5e74\u5386\u53f2\u4e2d&#xff0c;\u5168\u5c40\u89e3\u91ca\u5668\u9501&#xff08;Global Interpreter Lock, \u7b80\u79f0 GIL&#xff09; \u59cb\u7ec8\u662f\u60ac\u5728\u6240\u6709 Python \u67b6\u6784\u5e08\u4e0e\u9ad8\u6027\u80fd\u7cfb\u7edf\u5de5\u7a0b\u5e08\u5fc3\u5934\u7684\u4e00\u5757\u5de8\u5927\u9634\u973e\u3002 \u5c3d\u7ba1\u5f53\u4eca\u4e91\u539f\u751f\u73af\u5883\u4e0b\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u666e\u53ca\u4e86 32 \u6838\u300164 \u6838\u751a\u81f3 128 \u6838\u5fc3\u7684\u9ad8\u6027\u80fd\u5904\u7406\u5668&#xff0c;\u4f46\u5728\u4f20\u7edf\u7684 CPython \u89e3\u91ca\u5668\u4e2d&#xff0c;\u7531\u4e8e GIL \u7684\u5b58\u5728&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/115653.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-12T13:33:00+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012133259-6acce18b66166.webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115653.html","url":"https:\/\/www.wsisp.com\/helps\/115653.html","name":"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-12T13:33:00+00:00","dateModified":"2026-10-12T13:33:00+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115653.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115653.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115653.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python 3.13 \u81ea\u7531\u7ebf\u7a0b\uff08nogil\uff09\u6a21\u5f0f\u521d\u63a2\uff1a\u5b9e\u6d4b\u9ad8\u5e76\u53d1\u5411\u91cf\u77e9\u9635\u8fd0\u7b97\u4e0b\u7684\u771f\u591a\u7ebf\u7a0b\u7ea2\u5229"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=115653"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115653\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115653"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}