{"id":16496,"date":"2024-12-09T19:51:44","date_gmt":"2024-12-09T16:21:44","guid":{"rendered":"https:\/\/www.itpiran.net\/blog\/?p=16496"},"modified":"2024-12-09T19:51:44","modified_gmt":"2024-12-09T16:21:44","slug":"boosting-python-scripts-cython","status":"publish","type":"post","link":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/boosting-python-scripts-cython\/","title":{"rendered":"\u4f7f\u7528 Cython \u6539\u8fdb Python \u811a\u672c"},"content":{"rendered":"<h2 id=\"%d9%85%d9%82%d8%af%d9%85%d9%87\">\u4ecb\u7ecd<\/h2>\n<p>Python\u6216\u8bb8\u662f\u5f53\u4eca\u6700\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\u4e4b\u4e00\uff0c\u4f46\u5b83\u7684\u6548\u7387\u7edd\u5bf9\u4e0d\u662f\u6700\u9ad8\u7684\u3002\u5c24\u5176\u662f\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\uff0c\u7528\u6237\u4e3a\u4e86Python\u7684\u6613\u7528\u6027\u800c\u727a\u7272\u4e86\u6548\u7387\u3002.<\/p>\n<p>\u4f46\u8fd9\u5e76\u4e0d\u610f\u5473\u7740\u4f60\u4e0d\u80fd\u901a\u8fc7\u5176\u4ed6\u65b9\u5f0f\u52a0\u5feb\u901f\u5ea6\u3002Cython \u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u4e0d\u727a\u7272 Python \u672c\u8eab\u6613\u4e8e\u5b9e\u73b0\u7684\u529f\u80fd\u7684\u524d\u63d0\u4e0b\uff0c\u51cf\u5c11 Python \u811a\u672c\u7684\u8ba1\u7b97\u65f6\u95f4\u3002.<\/p>\n<p>\u672c\u6559\u7a0b\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Cython \u6765\u52a0\u901f Python \u811a\u672c\u3002\u6211\u4eec\u5c06\u89e3\u51b3\u4e00\u4e2a\u7b80\u5355\u4f46\u8ba1\u7b97\u91cf\u5de8\u5927\u7684\u4efb\u52a1\uff1a\u521b\u5efa\u4e00\u4e2a for \u5faa\u73af\uff0c\u904d\u5386\u4e00\u4e2a\u5305\u542b 10 \u4ebf\u4e2a\u6570\u5b57\u7684 Python \u5217\u8868\u5e76\u6c42\u548c\u3002\u7531\u4e8e\u5728\u8d44\u6e90\u53d7\u9650\u7684\u8bbe\u5907\u4e0a\u8fd0\u884c\u4ee3\u7801\u65f6\u65f6\u95f4\u81f3\u5173\u91cd\u8981\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u5982\u4f55\u5728 Raspberry Pi (RPi) \u4e0a\u4f7f\u7528 Cython \u5b9e\u73b0 Python \u4ee3\u7801\u3002Cython \u53ef\u4ee5\u663e\u8457\u63d0\u5347\u8ba1\u7b97\u901f\u5ea6\uff0c\u5c31\u50cf\u662f\u4f7f\u7528\u60f0\u6027\u6c42\u503c\u7a0b\u5e8f (Lazy) \u548c\u4f7f\u7528 Yozo \u7a0b\u5e8f (yozo) \u4e4b\u95f4\u7684\u5de8\u5927\u5dee\u5f02\u3002.<\/p>\n<h2 id=\"%d9%be%db%8c%d8%b4%d9%86%db%8c%d8%a7%d8%b2%d9%87%d8%a7-%d8%a8%d8%b1%d8%a7%db%8c-%d8%a8%d9%87%db%8c%d9%86%d9%87%d8%b3%d8%a7%d8%b2%db%8c-%d8%a7%d8%b3%da%a9%d8%b1%db%8c%d9%be%d8%aa\">\u4f7f\u7528 Cython \u4f18\u5316 Python \u811a\u672c\u7684\u524d\u63d0\u6761\u4ef6<\/h2>\n<ul>\n<li>Python\u57fa\u7840\u77e5\u8bc6\uff1a\u719f\u6089Python\u8bed\u6cd5\u3001\u51fd\u6570\u3001\u6570\u636e\u7c7b\u578b\u548c\u6a21\u5757\u3002.<\/li>\n<li>\u7406\u89e3 C\/C++ \u57fa\u672c\u6982\u5ff5\uff1a\u719f\u6089 C \u6216 C++ \u7684\u57fa\u672c\u6982\u5ff5\uff0c\u4f8b\u5982\u6307\u9488\u3001\u6570\u636e\u7c7b\u578b\u548c\u63a7\u5236\u7ed3\u6784\u3002.<\/li>\n<li>Python \u5f00\u53d1\u73af\u5883\uff1a\u4f7f\u7528 pip \u7b49\u5305\u7ba1\u7406\u5668\u5b89\u88c5 Python\uff08\u6700\u597d\u662f Python 3.x\uff09\u3002.<\/li>\n<li>\u5b89\u88c5 Cython\uff1a\u4f7f\u7528 pip install cython \u547d\u4ee4\u5b89\u88c5 Cython\u3002.<\/li>\n<li>\u7ec8\u7aef\/\u547d\u4ee4\u884c\u719f\u6089\u5ea6\uff1a\u5177\u5907\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u548c\u6267\u884c\u547d\u4ee4\u7684\u57fa\u672c\u80fd\u529b\u3002.<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u5148\u51b3\u6761\u4ef6\u5c06\u5e2e\u52a9\u4f60\u505a\u597d\u51c6\u5907\uff0c\u5f00\u59cb\u4f7f\u7528 Cython \u4f18\u5316 Python \u4ee3\u7801\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"262\"  class=\"aligncenter wp-image-16498 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1-300x136.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1-110x50.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1-200x91.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1-380x173.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1-255x116.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09183840\/1-550x250.png 550w\" ><\/a><\/p>\n<h2 id=\"%d9%be%d8%a7%db%8c%d8%aa%d9%88%d9%86-%d9%88-%d8%b3%db%8c%d9%be%d8%a7%db%8c%d8%aa%d9%88%d9%86\">Python \u548c CPython<\/h2>\n<p>\u5f88\u591a\u4eba\u5e76\u4e0d\u77e5\u9053\uff0c\u50cf Python \u8fd9\u6837\u7684\u8bed\u8a00\u5b9e\u9645\u4e0a\u662f\u7528\u5176\u4ed6\u8bed\u8a00\u5b9e\u73b0\u7684\u3002\u4f8b\u5982\uff0cPython \u7684 C \u8bed\u8a00\u5b9e\u73b0\u88ab\u79f0\u4e3a CPython\u3002\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e0e Cython \u4e0d\u540c\u3002\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u4e0d\u540c Python \u5b9e\u73b0\u7684\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u9605\u8bfb\u8fd9\u7bc7\u6587\u7ae0\u3002.<\/p>\n<p>Python \u7684\u9ed8\u8ba4\u4e14\u6700\u6d41\u884c\u7684\u5b9e\u73b0\u662f C-Python\u3002\u4f7f\u7528\u5b83\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u4f18\u52bf\u3002C \u662f\u4e00\u79cd\u7f16\u8bd1\u578b\u8bed\u8a00\uff0c\u5b83\u7684\u4ee3\u7801\u4f1a\u88ab\u8f6c\u6362\u6210\u673a\u5668\u4ee3\u7801\uff0c\u76f4\u63a5\u7531\u4e2d\u592e\u5904\u7406\u5668 (CPU) \u6267\u884c\u3002\u73b0\u5728\u4f60\u53ef\u80fd\u4f1a\u95ee\uff0c\u5982\u679c C \u662f\u7f16\u8bd1\u578b\u8bed\u8a00\uff0c\u90a3\u4e48 Python \u4e5f\u662f\u5417\uff1f<\/p>\n<p>C \u8bed\u8a00\u5b9e\u73b0\u7684 Python (Cpython) 100% \u65e2\u4e0d\u662f\u7f16\u8bd1\u578b\u7684\uff0c\u4e5f\u4e0d\u662f\u89e3\u91ca\u578b\u7684\u3002\u5b9e\u9645\u4e0a\uff0c\u7f16\u8bd1\u548c\u89e3\u91ca\u90fd\u662f\u5728\u6267\u884c Python \u811a\u672c\u7684\u8fc7\u7a0b\u4e2d\u53d1\u751f\u7684\u3002\u4e3a\u4e86\u66f4\u6e05\u695a\u5730\u8bf4\u660e\u8fd9\u4e00\u70b9\uff0c\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u6267\u884c Python \u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 CPython \u7f16\u8bd1\u6e90\u4ee3\u7801\u4ee5\u751f\u6210\u5b57\u8282\u7801<\/li>\n<li>CPython\u89e3\u91ca\u5668\u5bf9\u5b57\u8282\u7801\u7684\u89e3\u91ca<\/li>\n<li>\u5728 CPython \u865a\u62df\u673a\u4e2d\u8fd0\u884c CPython \u89e3\u91ca\u5668\u7684\u8f93\u51fa<\/li>\n<\/ol>\n<p>\u7f16\u8bd1\u8fc7\u7a0b\u662f\u6307 CPython \u7f16\u8bd1\u6e90\u4ee3\u7801\uff08.py \u6587\u4ef6\uff09\u5e76\u751f\u6210 CPython \u5b57\u8282\u7801\uff08.pyc \u6587\u4ef6\uff09\u3002\u7136\u540e\uff0cCPython \u89e3\u91ca\u5668\u4f1a\u89e3\u91ca\u8be5\u5b57\u8282\u7801\uff0c\u5e76\u5728 CPython \u865a\u62df\u673a\u4e2d\u6267\u884c\u5176\u8f93\u51fa\u3002\u5982\u4e0a\u6240\u793a\uff0c\u6267\u884c Python \u811a\u672c\u7684\u8fc7\u7a0b\u6d89\u53ca\u7f16\u8bd1\u548c\u89e3\u91ca\u4e24\u4e2a\u6b65\u9aa4\u3002.<\/p>\n<p>CPython \u7f16\u8bd1\u5668\u53ea\u751f\u6210\u4e00\u6b21\u5b57\u8282\u7801\uff0c\u4f46\u6bcf\u6b21\u6267\u884c\u4ee3\u7801\u65f6\u90fd\u4f1a\u8c03\u7528\u89e3\u91ca\u5668\u3002\u89e3\u91ca\u5b57\u8282\u7801\u901a\u5e38\u9700\u8981\u5f88\u957f\u65f6\u95f4\u3002\u5982\u679c\u4f7f\u7528\u89e3\u91ca\u5668\u4f1a\u964d\u4f4e\u6267\u884c\u901f\u5ea6\uff0c\u90a3\u4e3a\u4ec0\u4e48\u8fd8\u8981\u4f7f\u7528\u5b83\u5462\uff1f\u4e3b\u8981\u539f\u56e0\u662f\u89e3\u91ca\u5668\u4f7f Python \u80fd\u591f\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u3002\u7531\u4e8e\u5b57\u8282\u7801\u662f\u5728\u8fd0\u884c\u4e8e CPU \u4e0a\u7684 CPython \u865a\u62df\u673a\u4e2d\u72ec\u7acb\u4e8e\u673a\u5668\u6267\u884c\u7684\uff0c\u56e0\u6b64\u65e0\u9700\u4efb\u4f55\u4fee\u6539\u5373\u53ef\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\u8fd0\u884c\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"654\"  class=\"aligncenter wp-image-16499 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-264x300.png 264w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-110x125.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-200x227.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-380x431.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-255x290.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-300x341.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09184025\/2-550x624.png 550w\" ><\/a><\/p>\n<p>\u5982\u679c\u4e0d\u4f7f\u7528\u89e3\u91ca\u5668\uff0cCPython \u7f16\u8bd1\u5668\u5c06\u751f\u6210\u76f4\u63a5\u5728 CPU \u4e0a\u8fd0\u884c\u7684\u673a\u5668\u4ee3\u7801\u3002\u7531\u4e8e\u4e0d\u540c\u5e73\u53f0\u7684\u6307\u4ee4\u96c6\u4e0d\u540c\uff0c\u56e0\u6b64\u8be5\u4ee3\u7801\u65e0\u6cd5\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u8fd0\u884c\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"390\"  class=\"aligncenter wp-image-16500 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3-300x203.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3-110x74.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3-200x135.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3-380x257.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3-255x173.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09184215\/3-550x372.png 550w\" ><\/a><\/p>\n<p>\u7b80\u800c\u8a00\u4e4b\uff0c\u4f7f\u7528\u7f16\u8bd1\u5668\u53ef\u4ee5\u52a0\u5feb\u5904\u7406\u901f\u5ea6\uff0c\u800c\u89e3\u91ca\u5668\u5219\u4f7f\u4ee3\u7801\u80fd\u591f\u8de8\u5e73\u53f0\u8fd0\u884c\u3002\u56e0\u6b64\uff0cPython \u6bd4 C \u6162\u7684\u539f\u56e0\u4e4b\u4e00\u5c31\u662f\u4f7f\u7528\u4e86\u89e3\u91ca\u5668\u3002\u8bf7\u8bb0\u4f4f\uff0c\u7f16\u8bd1\u5668\u53ea\u8fd0\u884c\u4e00\u6b21\uff0c\u800c\u89e3\u91ca\u5668\u6bcf\u6b21\u6267\u884c\u4ee3\u7801\u65f6\u90fd\u4f1a\u8fd0\u884c\u3002.<\/p>\n<p>Python \u6bd4 C \u6162\u5f97\u591a\uff0c\u4f46\u8bb8\u591a\u7a0b\u5e8f\u5458\u4ecd\u7136\u66f4\u559c\u6b22\u5b83\uff0c\u56e0\u4e3a\u5b83\u66f4\u5bb9\u6613\u4f7f\u7528\u3002Python \u4e3a\u7a0b\u5e8f\u5458\u9690\u85cf\u4e86\u8bb8\u591a\u7ec6\u8282\uff0c\u8fd9\u53ef\u4ee5\u907f\u514d\u4ee4\u4eba\u6cae\u4e27\u7684\u8c03\u8bd5\u8fc7\u7a0b\u3002\u4f8b\u5982\uff0c\u7531\u4e8e Python \u662f\u4e00\u79cd\u52a8\u6001\u7c7b\u578b\u8bed\u8a00\uff0c\u56e0\u6b64\u65e0\u9700\u5728\u4ee3\u7801\u4e2d\u6307\u5b9a\u6bcf\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\u2014\u2014Python \u4f1a\u81ea\u52a8\u63a8\u65ad\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u5728\u9759\u6001\u7c7b\u578b\u8bed\u8a00\uff08\u4f8b\u5982 C\u3001C++ \u6216 Java\uff09\u4e2d\uff0c\u60a8\u5fc5\u987b\u6307\u5b9a\u53d8\u91cf\u7684\u7c7b\u578b\uff0c\u5982\u4e0b\u6240\u793a\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>int x = 10\r\nstring s = \"Hello\"<\/code><\/pre>\n<\/div>\n<p>\u4e0e\u4ee5\u4e0b Python \u5b9e\u73b0\u8fdb\u884c\u6bd4\u8f83\uff1a<\/p>\n<p>\u52a8\u6001\u7c7b\u578b\u4f7f\u7f16\u7801\u66f4\u5bb9\u6613\uff0c\u4f46\u5b83\u589e\u52a0\u4e86\u673a\u5668\u67e5\u627e\u6b63\u786e\u6570\u636e\u7c7b\u578b\u7684\u8d1f\u62c5\uff0c\u4ece\u800c\u51cf\u6162\u4e86\u6267\u884c\u901f\u5ea6\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>x = 10\r\ns = \"Hello\"<\/code><\/pre>\n<\/div>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u50cf Python \u8fd9\u6837\u7684\u201c\u9ad8\u7ea7\u201d\u8bed\u8a00\u5bf9\u5f00\u53d1\u8005\u6765\u8bf4\u66f4\u5bb9\u6613\u7406\u89e3\u3002\u4f46\u662f\uff0c\u4ee3\u7801\u6267\u884c\u65f6\u9700\u8981\u8f6c\u6362\u6210\u4f4e\u7ea7\u6307\u4ee4\u3002\u8fd9\u79cd\u8f6c\u6362\u9700\u8981\u66f4\u591a\u65f6\u95f4\uff0c\u800c\u8fd9\u662f\u4e3a\u4e86\u4fdd\u8bc1\u6613\u7528\u6027\u800c\u505a\u51fa\u7684\u727a\u7272\u3002.<\/p>\n<p>\u5982\u679c\u65f6\u95f4\u7d27\u8feb\uff0c\u4f60\u5e94\u8be5\u4f7f\u7528\u5e95\u5c42\u547d\u4ee4\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4e0e\u5176\u7528 Python\uff08\u524d\u7aef\u8bed\u8a00\uff09\u7f16\u5199\u4ee3\u7801\uff0c\u4e0d\u5982\u4f7f\u7528 CPython\uff0c\u5b83\u5e95\u5c42\u4e5f\u662f\u7528 Python \u7f16\u5199\u7684\uff0c\u4f46\u5e95\u5c42\u662f\u7528 C \u8bed\u8a00\u5b9e\u73b0\u7684\u3002\u4e0d\u8fc7\uff0c\u8fd9\u6837\u505a\u7684\u8bdd\uff0c\u4f60\u4f1a\u611f\u89c9\u81ea\u5df1\u50cf\u662f\u5728\u7528 C \u8bed\u8a00\u7f16\u7a0b\uff0c\u800c\u4e0d\u662f Python\u3002.<\/p>\n<p>CPython \u8981\u590d\u6742\u5f97\u591a\u3002\u5728 CPython \u4e2d\uff0c\u6240\u6709\u4ee3\u7801\u90fd\u662f\u7528 C \u8bed\u8a00\u5b9e\u73b0\u7684\u3002\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u65e0\u6cd5\u907f\u514d C \u8bed\u8a00\u7684\u590d\u6742\u6027\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u8bb8\u591a\u5f00\u53d1\u8005\u9009\u62e9\u4f7f\u7528 Cython \u7684\u539f\u56e0\u3002\u90a3\u4e48\uff0cCython \u4e0e CPython \u7a76\u7adf\u6709\u4f55\u4e0d\u540c\u5462\uff1f<\/p>\n<h2 id=\"cython-%da%86%da%af%d9%88%d9%86%d9%87-%d9%85%d8%aa%d9%81%d8%a7%d9%88%d8%aa-%d8%a7%d8%b3%d8%aa\">Cython \u6709\u4f55\u4e0d\u540c\uff1f<\/h2>\n<p>\u5982\u4e0a\u6240\u8ff0\uff0cCython \u662f\u4e00\u79cd\u517c\u5177\u901f\u5ea6\u548c\u6613\u7528\u6027\u7684\u8bed\u8a00\u3002\u60a8\u4ecd\u7136\u53ef\u4ee5\u7528 Python \u7f16\u5199\u5e38\u89c4\u4ee3\u7801\uff0c\u4f46\u4e3a\u4e86\u63d0\u9ad8\u6267\u884c\u901f\u5ea6\uff0cCython \u5141\u8bb8\u60a8\u7528 C \u4ee3\u7801\u66ff\u6362\u90e8\u5206 Python \u4ee3\u7801\u3002\u8fd9\u6837\uff0c\u60a8\u6700\u7ec8\u53ef\u4ee5\u5c06\u4e24\u79cd\u8bed\u8a00\u7ed3\u5408\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d\u3002\u8bf7\u6ce8\u610f\uff0c\u60a8\u53ef\u4ee5\u60f3\u8c61 Python \u4e2d\u7684\u6240\u6709\u4ee3\u7801\u5728 Cython \u4e2d\u90fd\u6709\u6548\uff0c\u4f46\u5b58\u5728\u4e00\u4e9b\u9650\u5236\u3002.<\/p>\n<p>\u666e\u901a\u7684 Python \u6587\u4ef6\u6269\u5c55\u540d\u4e3a .py\uff0c\u800c Cython \u6587\u4ef6\u6269\u5c55\u540d\u4e3a .pyx\u3002\u540c\u6837\u7684 Python \u4ee3\u7801\u53ef\u4ee5\u5199\u5728 .pyx \u6587\u4ef6\u4e2d\uff0c\u4f46\u8fd9\u4e9b\u6587\u4ef6\u4e5f\u5141\u8bb8\u4f60\u4f7f\u7528 Cython \u4ee3\u7801\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5c06 Python \u4ee3\u7801\u653e\u5728 .pyx \u6587\u4ef6\u4e2d\u53ef\u80fd\u6bd4\u76f4\u63a5\u8fd0\u884c Python \u4ee3\u7801\u66f4\u5feb\uff0c\u4f46\u4e0d\u5982\u58f0\u660e\u53d8\u91cf\u7c7b\u578b\u6765\u5f97\u5feb\u3002\u56e0\u6b64\uff0c\u672c\u6559\u7a0b\u7684\u91cd\u70b9\u4e0d\u4ec5\u5728\u4e8e\u5982\u4f55\u5728 .pyx \u6587\u4ef6\u4e2d\u7f16\u5199 Python \u4ee3\u7801\uff0c\u8fd8\u5728\u4e8e\u5982\u4f55\u8fdb\u884c\u4fee\u6539\u4ee5\u63d0\u5347\u4ee3\u7801\u8fd0\u884c\u901f\u5ea6\u3002\u8fd9\u4f1a\u589e\u52a0\u4e00\u4e9b\u7f16\u7a0b\u7684\u590d\u6742\u6027\uff0c\u4f46\u53ef\u4ee5\u8282\u7701\u5927\u91cf\u65f6\u95f4\u3002\u5982\u679c\u4f60\u6709\u4e00\u4e9b C \u8bed\u8a00\u7f16\u7a0b\u7ecf\u9a8c\uff0c\u8fd9\u5c06\u66f4\u5bb9\u6613\u7406\u89e3\u3002.<\/p>\n<h2 id=\"%d8%b3%d8%a7%db%8c%d8%aa%d8%b1%d9%88%d9%86-%da%a9%d8%b1%d8%af%d9%86-%da%a9%d8%af-%d8%b3%d8%a7%d8%af%d9%87-%d9%be%d8%a7%db%8c%d8%aa%d9%88%d9%86\">\u7b80\u5355\u7684 Python \u4ee3\u7801<\/h2>\n<p>\u8981\u5c06 Python \u4ee3\u7801\u8f6c\u6362\u4e3a Cython\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6269\u5c55\u540d\u4e3a .py \u7684\u6587\u4ef6\u3002 <code inline=\"\">.pyx<\/code> \u521b\u5efa\u800c\u975e\u6269\u5c55 <code inline=\"\">.py<\/code>. \u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u5e38\u89c4\u7684 Python \u4ee3\u7801\uff08\u8bf7\u6ce8\u610f\uff0cCython \u5bf9\u4ee3\u7801\u6709\u4e00\u4e9b\u9650\u5236\uff0c\u8fd9\u4e9b\u9650\u5236\u5728 Cython \u6587\u6863\u4e2d\u6709\u8bf4\u660e\uff09\u3002.<\/p>\n<p>\u5728\u7ee7\u7eed\u64cd\u4f5c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u5b89\u88c5 Cython\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b8c\u6210\u6b64\u64cd\u4f5c\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>pip install cython\r\n<\/code><\/pre>\n<\/div>\n<p>\u8981\u751f\u6210 .pyd\/.so \u6587\u4ef6\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u6784\u5efa Cython \u6587\u4ef6\u3002.pyd\/.so \u6587\u4ef6\u4ee3\u8868\u6211\u4eec\u7a0d\u540e\u5c06\u8981\u5bfc\u5165\u7684\u6a21\u5757\u3002\u6784\u5efa Cython \u6587\u4ef6\u9700\u8981\u4f7f\u7528 setup.py \u6587\u4ef6\u3002\u521b\u5efa\u6b64\u6587\u4ef6\u5e76\u5c06\u4ee5\u4e0b\u4ee3\u7801\u653e\u5165\u5176\u4e2d\u3002\u6211\u4eec\u5c06\u4f7f\u7528 distutils.core.setup() \u51fd\u6570\u8c03\u7528 Cython.Build.cythonize() \u51fd\u6570\uff0c\u8be5\u51fd\u6570\u5c06\u5bf9 .pyx \u6587\u4ef6\u8fdb\u884c Cyanogenize \u5904\u7406\u3002\u6b64\u51fd\u6570\u63a5\u53d7\u8981\u8fdb\u884c Cyanogenize \u5904\u7406\u7684\u6587\u4ef6\u7684\u8def\u5f84\u3002\u8fd9\u91cc\uff0c\u6211\u5047\u8bbe setup.py \u6587\u4ef6\u4e0e test_cython.pyx \u6587\u4ef6\u4f4d\u4e8e\u540c\u4e00\u76ee\u5f55\u4e0b\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import distutils.core\r\nimport Cython.Build\r\ndistutils.core.setup(\r\next_modules = Cython.Build.cythonize(\"test_cython.pyx\"))<\/code><\/pre>\n<\/div>\n<p>\u8981\u6784\u5efa Cython \u6587\u4ef6\uff0c\u8bf7\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u3002\u547d\u4ee4\u884c\u5f53\u524d\u76ee\u5f55\u5fc5\u987b\u4e0e setup.py \u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u76f8\u540c\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>python setup.py build_ext --inplace\r\n<\/code><\/pre>\n<\/div>\n<p>\u6b64\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u4f1a\u5728 .pyx \u6587\u4ef6\u65c1\u8fb9\u751f\u6210\u4e24\u4e2a\u6587\u4ef6\u3002\u7b2c\u4e00\u4e2a\u6587\u4ef6\u7684\u6269\u5c55\u540d\u4e3a .c\uff0c\u53e6\u4e00\u4e2a\u6587\u4ef6\u7684\u6269\u5c55\u540d\u4e3a .pyd\uff08\u6216\u7c7b\u4f3c\u6269\u5c55\u540d\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u64cd\u4f5c\u7cfb\u7edf\uff09\u3002\u8981\u4f7f\u7528\u751f\u6210\u7684\u6587\u4ef6\uff0c\u53ea\u9700\u5bfc\u5165 test_cython \u6a21\u5757\uff0c\u5373\u53ef\u76f4\u63a5\u663e\u793a\u201cHello Cython\u201d\u6d88\u606f\uff0c\u5982\u4e0b\u6240\u793a\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185034\/4.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"195\"  height=\"47\"  class=\"aligncenter wp-image-16501 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 195px) 100vw, 195px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185034\/4.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185034\/4.png 195w, https:\/\/cdn.itpiran.net\/2024\/12\/09185034\/4-110x27.png 110w\" ><\/a><\/p>\n<p>\u6211\u4eec\u73b0\u5728\u5df2\u7ecf\u6210\u529f\u5730\u5bf9 Python \u4ee3\u7801\u8fdb\u884c\u4e86 Cyton \u5316\u3002\u4e0b\u4e00\u8282\u5c06\u4ecb\u7ecd\u5982\u4f55\u5bf9\u5305\u542b\u5faa\u73af\u7684 .pyx \u6587\u4ef6\u8fdb\u884c Cyton \u5316\u3002.<\/p>\n<p>\u80de\u8d28\u5206\u88c2\u201cfor\u201d\u73af\u201d<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u6765\u4f18\u5316\u4e4b\u524d\u7684\u4efb\u52a1\uff1a\u4e00\u4e2a\u904d\u5386\u4e00\u767e\u4e07\u4e2a\u6570\u5b57\u5e76\u6c42\u548c\u7684 for \u5faa\u73af\u3002\u9996\u5148\uff0c\u6211\u4eec\u6765\u8003\u5bdf\u4e00\u4e0b\u5faa\u73af\u672c\u8eab\u7684\u6548\u7387\u3002\u65f6\u95f4\u6a21\u5757\u4f1a\u7528\u6765\u4f30\u7b97\u5faa\u73af\u7684\u6267\u884c\u65f6\u95f4\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import time\r\nt1 = time.time()\r\nfor k in range(1000000):\r\npass\r\nt2 = time.time()\r\nt = t2-t1\r\nprint(\"%.20f\" % t)<\/code><\/pre>\n<\/div>\n<p>\u5728\u4e00\u4e2a .pyx \u6587\u4ef6\u4e2d\uff0c\u6267\u884c 3 \u6b21\u7684\u5e73\u5747\u65f6\u95f4\u4e3a 0.0281 \u79d2\u3002\u8be5\u4ee3\u7801\u8fd0\u884c\u5728\u4e00\u53f0\u914d\u5907 Core i7-6500U @ 2.5 GHz \u5904\u7406\u5668\u548c 16 GB DDR3 \u5185\u5b58\u7684\u673a\u5668\u4e0a\u3002.<\/p>\n<p>\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u5178\u578b\u7684 Python \u6587\u4ef6\u6267\u884c\u65f6\u95f4\u5e73\u5747\u4e3a 0.0411 \u79d2\u3002\u8fd9\u610f\u5473\u7740\uff0c\u5373\u4f7f\u4e0d\u4fee\u6539 for \u5faa\u73af\u4f7f\u5176\u4ee5 C \u8bed\u8a00\u7684\u901f\u5ea6\u8fd0\u884c\uff0cCython \u5728\u8fed\u4ee3\u6b21\u6570\u4e0a\u4e5f\u4ec5\u6bd4 Python \u5feb 1.46 \u500d\u3002.<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u6765\u6dfb\u52a0\u52a0\u6cd5\u8fd0\u7b97\u3002\u6211\u4eec\u5c06\u4f7f\u7528 range() \u51fd\u6570\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import time\r\nt1 = time.time()\r\ntotal = 0\r\nfor k in range(1000000):\r\ntotal = total + k\r\nprint \"Total =\", total\r\nt2 = time.time()\r\nt = t2-t1\r\nprint(\"%.100f\" % t)<\/code><\/pre>\n<\/div>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4e24\u4e2a\u811a\u672c\u8fd4\u56de\u7684\u503c\u76f8\u540c\uff0c\u5747\u4e3a 499999500000\u3002\u5728 Python \u4e2d\uff0c\u8be5\u811a\u672c\u5e73\u5747\u8fd0\u884c\u65f6\u95f4\u4e3a 0.1183 \u79d2\uff08\u4e09\u6b21\u6d4b\u8bd5\u7ed3\u679c\uff09\u3002\u5728 Cython \u4e2d\uff0c\u901f\u5ea6\u63d0\u5347\u4e86 1.35 \u500d\uff0c\u5e73\u5747\u8fd0\u884c\u65f6\u95f4\u4e3a 0.0875 \u79d2\u3002.<\/p>\n<p>\u73b0\u5728\u8ba9\u6211\u4eec\u6765\u770b\u53e6\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5faa\u73af\u4ece 0 \u5f00\u59cb\uff0c\u904d\u5386 10 \u4ebf\u4e2a\u6570\u5b57\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import time\r\nt1 = time.time()\r\ntotal = 0\r\nfor k in range(1000000000):\r\ntotal = total + k\r\nprint \"Total =\", total\r\nt2 = time.time()\r\nt = t2-t1\r\nprint(\"%.20f\" % t)<\/code><\/pre>\n<\/div>\n<p>Cython\u811a\u672c\u5927\u7ea6\u8017\u65f685\u79d2\uff081.4\u5206\u949f\uff09\u5b8c\u6210\uff0c\u800cPython\u811a\u672c\u5927\u7ea6\u8017\u65f6115\u79d2\uff081.9\u5206\u949f\uff09\u5b8c\u6210\u3002\u4e24\u79cd\u65b9\u5f0f\u90fd\u8017\u65f6\u8fc7\u957f\u3002\u5982\u679c\u5b8c\u6210\u8fd9\u6837\u4e00\u4e2a\u7b80\u5355\u7684\u4efb\u52a1\u90fd\u9700\u8981\u4e00\u5206\u949f\u4ee5\u4e0a\uff0c\u90a3\u4e48\u4f7f\u7528Cython\u7684\u610f\u4e49\u4f55\u5728\uff1f\u8bf7\u6ce8\u610f\uff0c\u8fd9\u662f\u6211\u4eec\u7684\u95ee\u9898\uff0c\u5e76\u975eCython\u7684\u95ee\u9898\u3002.<\/p>\n<p>\u5982\u524d\u6240\u8ff0\uff0c\u5728 Cython \u811a\u672c (.pyx) \u4e2d\u7f16\u5199 Python \u4ee3\u7801\u662f\u4e00\u79cd\u6539\u8fdb\uff0c\u4f46\u5bf9\u8fd0\u884c\u65f6\u6027\u80fd\u7684\u5f71\u54cd\u5e76\u4e0d\u663e\u8457\u3002\u6211\u4eec\u9700\u8981\u5bf9 Cython \u811a\u672c\u4e2d\u7684 Python \u4ee3\u7801\u8fdb\u884c\u4e00\u4e9b\u4fee\u6539\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u663e\u5f0f\u58f0\u660e\u6240\u7528\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b\u3002.<\/p>\n<h2 id=\"%d8%aa%d8%ae%d8%b5%db%8c%d8%b5-%d9%86%d9%88%d8%b9-%d8%af%d8%a7%d8%af%d9%87-c-%d8%a8%d9%87-%d9%85%d8%aa%d8%ba%db%8c%d8%b1%d9%87%d8%a7\">\u5c06 C \u6570\u636e\u7c7b\u578b\u5206\u914d\u7ed9\u53d8\u91cf<\/h2>\n<p>\u6839\u636e\u4e4b\u524d\u7684\u4ee3\u7801\uff0c\u4f7f\u7528\u4e86 5 \u4e2a\u53d8\u91cf\uff1atotal\u3001k\u3001t1\u3001t2 \u548c t\u3002\u8fd9\u4e9b\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b\u90fd\u662f\u7531\u4ee3\u7801\u9690\u5f0f\u63a8\u65ad\u7684\uff0c\u56e0\u6b64\u8017\u65f6\u8f83\u957f\u3002\u4e3a\u4e86\u8282\u7701\u63a8\u65ad\u6570\u636e\u7c7b\u578b\u7684\u65f6\u95f4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 C \u8bed\u8a00\u7684\u6570\u636e\u7c7b\u578b\u5b9a\u4e49\u6765\u6307\u5b9a\u5b83\u4eec\u3002.<\/p>\n<p>\u53d8\u91cf total \u7684\u7c7b\u578b\u662f unsigned long long int\u3002\u5b83\u662f\u6574\u6570\u7c7b\u578b\uff0c\u56e0\u4e3a\u6240\u6709\u6570\u5b57\u4e4b\u548c\u662f\u6574\u6570\uff1b\u5b83\u662f\u65e0\u7b26\u53f7\u7c7b\u578b\uff0c\u56e0\u4e3a\u548c\u59cb\u7ec8\u4e3a\u6b63\u6570\u3002\u4f46\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528 long long \u7c7b\u578b\u5462\uff1f\u56e0\u4e3a\u6240\u6709\u6570\u5b57\u4e4b\u548c\u975e\u5e38\u5927\uff0c\u6240\u4ee5\u4f7f\u7528 long long \u7c7b\u578b\u6765\u5c3d\u53ef\u80fd\u5730\u589e\u5927\u53d8\u91cf\u7684\u503c\u3002.<\/p>\n<p>\u53d8\u91cf k \u7684\u6570\u636e\u7c7b\u578b\u4e3a int\uff0c\u5176\u4f59\u4e09\u4e2a\u53d8\u91cf t1\u3001t2 \u548c t \u7684\u6570\u636e\u7c7b\u578b\u4e3a float\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import time\r\ncdef unsigned long long int total\r\ncdef int k\r\ncdef float t1, t2, t\r\nt1 = time.time()\r\nfor k in range(1000000000):\r\ntotal = total + k\r\nprint \"Total =\", total\r\nt2 = time.time()\r\nt = t2-t1\r\nprint(\"%.100f\" % t)<\/code><\/pre>\n<\/div>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6700\u540e\u4e00\u6761\u6253\u5370\u8bed\u53e5\u4e2d\u5b9a\u4e49\u7684\u7cbe\u5ea6\u8bbe\u7f6e\u4e3a 100\uff0c\u800c\u6240\u6709\u8fd9\u4e9b\u6570\u5b57\u90fd\u4e3a\u96f6\uff08\u53c2\u89c1\u4e0b\u4e00\u5f20\u56fe\uff09\u3002\u8fd9\u5c31\u662f\u4f7f\u7528 Cython \u7684\u9884\u671f\u7ed3\u679c\u3002Python \u9700\u8981\u8d85\u8fc7 1.9 \u5206\u949f\uff0c\u800c Cython \u51e0\u4e4e\u4e0d\u8017\u65f6\u3002\u6211\u751a\u81f3\u4e0d\u4f1a\u8bf4\u5b83\u6bd4 Python \u5feb 1000 \u500d\u6216 100000 \u500d\uff1b\u6211\u5c1d\u8bd5\u4e86\u4e0d\u540c\u7684\u6253\u5370\u65f6\u95f4\u7cbe\u5ea6\uff0c\u4ecd\u7136\u6ca1\u6709\u663e\u793a\u4efb\u4f55\u6570\u5b57\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"44\"  class=\"aligncenter wp-image-16502 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5-300x23.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5-110x8.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5-200x15.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5-380x29.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5-255x19.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09185717\/5-550x42.png 550w\" ><\/a><\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u60a8\u8fd8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6574\u578b\u53d8\u91cf\u6765\u4fdd\u5b58\u4f20\u9012\u7ed9 range() \u51fd\u6570\u7684\u503c\u3002\u8fd9\u5c06\u8fdb\u4e00\u6b65\u63d0\u9ad8\u6027\u80fd\u3002\u65b0\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff0c\u5176\u4e2d\u503c\u5b58\u50a8\u5728\u6574\u578b\u53d8\u91cf maxval \u4e2d\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code>import time\r\ncdef unsigned long long int maxval\r\ncdef unsigned long long int total\r\ncdef int k\r\ncdef float t1, t2, t\r\nmaxval=1000000000\r\nt1=time.time()\r\nfor k in range(maxval):\r\ntotal = total + k\r\nprint \"Total =\", total\r\nt2=time.time()\r\nt = t2-t1\r\nprint(\"%.100f\" % t)<\/code><\/pre>\n<\/div>\n<p>\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u4e86\u89e3\u4e86\u5982\u4f55\u4f7f\u7528 Cython \u63d0\u9ad8 Python \u811a\u672c\u7684\u6027\u80fd\uff0c\u90a3\u4e48\u8ba9\u6211\u4eec\u5c06\u5176\u5e94\u7528\u5230 Raspberry Pi (RPi) \u4e0a\u3002.<\/p>\n<h2 id=\"%d8%af%d8%b3%d8%aa%d8%b1%d8%b3%d9%be%d8%b0%db%8c%d8%b1%db%8c-raspberry-pi-%d8%a7%d8%b2-%da%a9%d8%a7%d9%85%d9%be%db%8c%d9%88%d8%aa%d8%b1-%d8%b4%d8%ae%d8%b5%db%8c\">\u901a\u8fc7\u4e2a\u4eba\u7535\u8111\u8bbf\u95ee\u6811\u8393\u6d3e<\/h2>\n<p>\u5982\u679c\u60a8\u662f\u7b2c\u4e00\u6b21\u4f7f\u7528\u6811\u8393\u6d3e\uff0c\u9700\u8981\u5c06\u60a8\u7684\u7535\u8111\u548c\u6811\u8393\u6d3e\u8fde\u63a5\u5230\u7f51\u7edc\u3002\u60a8\u53ef\u4ee5\u5c06\u4e24\u53f0\u8bbe\u5907\u8fde\u63a5\u5230\u4e00\u53f0\u542f\u7528\u4e86 DHCP\uff08\u52a8\u6001\u4e3b\u673a\u914d\u7f6e\u534f\u8bae\uff09\u529f\u80fd\u7684\u4ea4\u6362\u673a\uff0c\u4ee5\u4fbf\u81ea\u52a8\u5206\u914d IP \u5730\u5740\u3002\u7f51\u7edc\u521b\u5efa\u6210\u529f\u540e\uff0c\u60a8\u5c31\u53ef\u4ee5\u901a\u8fc7\u5206\u914d\u7ed9\u6811\u8393\u6d3e\u7684 IPv4 \u5730\u5740\u8bbf\u95ee\u5b83\u4e86\u3002\u5982\u4f55\u627e\u5230\u6811\u8393\u6d3e\u7684 IPv4 \u5730\u5740\u5462\uff1f\u522b\u62c5\u5fc3\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 IP \u5730\u5740\u626b\u63cf\u5de5\u5177\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u4f7f\u7528\u4e00\u6b3e\u540d\u4e3a Advanced IP Scanner \u7684\u514d\u8d39\u5e94\u7528\u7a0b\u5e8f\u3002.<\/p>\n<p>\u6b64\u5e94\u7528\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\u5982\u4e0b\u6240\u793a\u3002\u6b64\u5e94\u7528\u7a0b\u5e8f\u63a5\u53d7\u4e00\u7cfb\u5217 IPv4 \u5730\u5740\u8fdb\u884c\u641c\u7d22\uff0c\u5e76\u8fd4\u56de\u6709\u5173\u6d3b\u52a8\u8bbe\u5907\u7684\u4fe1\u606f\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"366\"  class=\"aligncenter wp-image-16503 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6-300x191.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6-110x70.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6-200x127.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6-380x241.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6-255x162.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09185936\/6-550x349.png 550w\" ><\/a><\/p>\n<p>\u60a8\u9700\u8981\u8f93\u5165\u672c\u5730\u7f51\u7edc\u7684 IPv4 \u5730\u5740\u8303\u56f4\u3002\u5982\u679c\u60a8\u4e0d\u77e5\u9053\u6b64\u8303\u56f4\uff0c\u53ea\u9700\u5728 Windows \u7cfb\u7edf\u4e2d\u8fd0\u884c ipconfig \u547d\u4ee4\uff08\u6216\u5728 Linux \u7cfb\u7edf\u4e2d\u8fd0\u884c ifconfig \u547d\u4ee4\uff09\u5373\u53ef\u627e\u5230\u8ba1\u7b97\u673a\u7684 IPv4 \u5730\u5740\uff08\u5982\u4e0b\u56fe\u6240\u793a\uff09\u3002\u5728\u6211\u7684\u793a\u4f8b\u4e2d\uff0c\u5206\u914d\u7ed9\u8ba1\u7b97\u673a Wi-Fi \u9002\u914d\u5668\u7684 IPv4 \u5730\u5740\u4e3a 192.168.43.177\uff0c\u5b50\u7f51\u63a9\u7801\u4e3a 255.255.255.0\u3002\u8fd9\u610f\u5473\u7740\u7f51\u7edc\u4e0a\u7684 IPv4 \u5730\u5740\u8303\u56f4\u4e3a 192.168.43.1 \u5230 192.168.43.255\u3002\u5982\u56fe\u6240\u793a\uff0cIPv4 \u5730\u5740 192.168.43.1 \u5206\u914d\u7ed9\u4e86\u7f51\u5173\u3002\u8bf7\u6ce8\u610f\uff0c\u6b64\u8303\u56f4\u5185\u7684\u6700\u540e\u4e00\u4e2a IPv4 \u5730\u5740 192.168.43.255 \u4fdd\u7559\u7528\u4e8e\u5e7f\u64ad\u6d88\u606f\u3002\u56e0\u6b64\uff0c\u60a8\u5e94\u8be5\u641c\u7d22\u7684\u8303\u56f4\u4ece 192.168.43.2 \u5f00\u59cb\uff0c\u5230 192.168.43.254 \u7ed3\u675f\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"544\"  height=\"170\"  class=\"aligncenter wp-image-16504 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 544px) 100vw, 544px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7.png 544w, https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7-300x94.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7-110x34.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7-200x63.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7-380x119.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09190052\/7-255x80.png 255w\" ><\/a><\/p>\n<p>\u6839\u636e\u4e0b\u56fe\u6240\u793a\u7684\u626b\u63cf\u7ed3\u679c\uff0c\u5206\u914d\u7ed9 RPi \u7684 IPv4 \u5730\u5740\u4e3a 192.168.43.63\u3002\u8be5 IPv4 \u5730\u5740\u53ef\u7528\u4e8e\u5efa\u7acb\u5b89\u5168\u5916\u58f3 (SSH) \u4f1a\u8bdd\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"366\"  class=\"aligncenter wp-image-16505 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8-300x191.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8-110x70.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8-200x127.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8-380x241.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8-255x162.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09190516\/8-550x349.png 550w\" ><\/a><\/p>\n<p>\u4e3a\u4e86\u5efa\u7acbSSH\u4f1a\u8bdd\uff0c\u6211\u5c06\u4f7f\u7528\u4e00\u6b3e\u540d\u4e3aMobaXterm\u7684\u514d\u8d39\u8f6f\u4ef6\u3002\u8be5\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\u5982\u4e0b\u6240\u793a\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"307\"  class=\"aligncenter wp-image-16506 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9-300x160.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9-110x59.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9-200x107.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9-380x203.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9-255x136.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09190623\/9-550x293.png 550w\" ><\/a><\/p>\n<p>\u8981\u521b\u5efa SSH \u4f1a\u8bdd\uff0c\u53ea\u9700\u70b9\u51fb\u5de6\u4e0a\u89d2\u7684\u201c\u4f1a\u8bdd\u201d\u6309\u94ae\u3002\u6b64\u65f6\u5c06\u51fa\u73b0\u4e00\u4e2a\u65b0\u7a97\u53e3\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"387\"  class=\"aligncenter wp-image-16507 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10-300x202.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10-110x74.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10-200x134.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10-380x255.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10-255x171.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09190749\/10-550x370.png 550w\" ><\/a><\/p>\n<p>\u5728\u6b64\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2\u7684 SSH \u6309\u94ae\uff0c\u6253\u5f00\u5982\u4e0b\u6240\u793a\u7684\u7a97\u53e3\u3002\u53ea\u9700\u8f93\u5165\u6811\u8393\u6d3e\u7684 IPv4 \u5730\u5740\u548c\u7528\u6237\u540d\uff08\u9ed8\u8ba4\u4e3a pi\uff09\uff0c\u7136\u540e\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u5373\u53ef\u5f00\u59cb\u4f1a\u8bdd\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"387\"  class=\"aligncenter wp-image-16508 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11-300x202.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11-110x74.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11-200x134.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11-380x255.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11-255x171.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09190859\/11-550x370.png 550w\" ><\/a><\/p>\n<p>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\u540e\uff0c\u5c06\u51fa\u73b0\u4e00\u4e2a\u65b0\u7a97\u53e3\uff0c\u8981\u6c42\u60a8\u8f93\u5165\u5bc6\u7801\u3002\u9ed8\u8ba4\u5bc6\u7801\u4e3a raspberrypi\u3002\u767b\u5f55\u540e\uff0c\u5c06\u51fa\u73b0\u4ee5\u4e0b\u7a97\u53e3\u3002\u5de6\u4fa7\u9762\u677f\u53ef\u5e2e\u52a9\u60a8\u8f7b\u677e\u6d4f\u89c8 Raspberry Pi \u7684\u5404\u4e2a\u76ee\u5f55\u3002\u6b64\u5916\uff0c\u8fd8\u6709\u4e00\u4e2a\u547d\u4ee4\u884c\u7a97\u53e3\u4f9b\u60a8\u8f93\u5165\u547d\u4ee4\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"307\"  class=\"aligncenter wp-image-16509 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12-300x160.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12-110x59.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12-200x107.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12-380x203.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12-255x136.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09190959\/12-550x293.png 550w\" ><\/a><\/p>\n<h2 id=\"%d8%a7%d8%b3%d8%aa%d9%81%d8%a7%d8%af%d9%87-%d8%a7%d8%b2-cython-%d8%a8%d8%a7-raspberry-pi\">\u5728\u6811\u8393\u6d3e\u4e0a\u4f7f\u7528 Cython<\/h2>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u6269\u5c55\u540d\u66f4\u6539\u4e3a .pyx\uff0c\u5373\u53ef\u5199\u5165\u4e0a\u4e00\u4e2a\u793a\u4f8b\u4e2d\u7684\u4ee3\u7801\u3002\u5de6\u4fa7\u9762\u677f\u680f\u63d0\u4f9b\u4e86\u521b\u5efa\u65b0\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u9009\u9879\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u65b0\u5efa\u6587\u4ef6\u56fe\u6807\u6765\u7b80\u5316\u64cd\u4f5c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002\u6211\u5728 Raspberry Pi \u7684\u6839\u76ee\u5f55\u4e2d\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a test_cython.pyx \u7684\u6587\u4ef6\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191116\/14.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"223\"  height=\"328\"  class=\"aligncenter wp-image-16510 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 223px) 100vw, 223px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191116\/14.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191116\/14.png 223w, https:\/\/cdn.itpiran.net\/2024\/12\/09191116\/14-204x300.png 204w, https:\/\/cdn.itpiran.net\/2024\/12\/09191116\/14-110x162.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09191116\/14-200x294.png 200w\" ><\/a><\/p>\n<p>\u53cc\u51fb\u6587\u4ef6\u6253\u5f00\uff0c\u7c98\u8d34\u4ee3\u7801\u5e76\u4fdd\u5b58\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa setup.py \u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u4e0e\u4e4b\u524d\u8ba8\u8bba\u7684\u5b8c\u5168\u76f8\u540c\u3002\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6784\u5efa Cython \u811a\u672c\u3002.<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>python3 setup.py build_ext --inplace\r\n<\/code><\/pre>\n<\/div>\n<p>\u6b64\u547d\u4ee4\u6210\u529f\u6267\u884c\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5de6\u4fa7\u9762\u677f\u4e2d\u627e\u5230\u8f93\u51fa\u6587\u4ef6\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002\u8bf7\u6ce8\u610f\uff0c\u7531\u4e8e\u6211\u4eec\u4e0d\u518d\u4f7f\u7528 Windows \u7cfb\u7edf\uff0c\u56e0\u6b64\u8981\u5bfc\u5165\u7684\u6a21\u5757\u6269\u5c55\u540d\u73b0\u5728\u662f .so\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"521\"  height=\"386\"  class=\"aligncenter wp-image-16511 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 521px) 100vw, 521px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15.png 521w, https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15-300x222.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15-110x81.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15-200x148.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15-380x282.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09191406\/15-255x189.png 255w\" ><\/a><\/p>\n<p>\u73b0\u5728\u6211\u4eec\u6fc0\u6d3b Python \u5e76\u5bfc\u5165\u6a21\u5757\uff0c\u5982\u4e0b\u6240\u793a\u3002\u8fd9\u91cc\u5f97\u5230\u7684\u7ed3\u679c\u4e0e\u5728 PC \u4e0a\u5b8c\u5168\u76f8\u540c\uff1b\u8017\u65f6\u51e0\u4e4e\u4e3a\u96f6\u3002.<\/p>\n<p><a href=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16.png\"><img  loading=\"lazy\"  decoding=\"async\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"576\"  height=\"94\"  class=\"aligncenter wp-image-16512 size-full pk-lazyload\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 576px) 100vw, 576px\"  data-pk-src=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16.png\"  data-pk-srcset=\"https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16.png 576w, https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16-300x49.png 300w, https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16-110x18.png 110w, https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16-200x33.png 200w, https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16-380x62.png 380w, https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16-255x42.png 255w, https:\/\/cdn.itpiran.net\/2024\/12\/09191524\/16-550x90.png 550w\" ><\/a><\/p>\n<h2 id=\"%d9%86%d8%aa%db%8c%d8%ac%d9%87\">\u7ed3\u679c<\/h2>\n<p>\u672c\u6559\u7a0b\u63a2\u8ba8\u4e86\u5982\u4f55\u4f7f\u7528 Cython \u6765\u51cf\u5c11\u8fd0\u884c Python \u811a\u672c\u7684\u8ba1\u7b97\u65f6\u95f4\u3002\u6211\u4eec\u5c06\u5411\u60a8\u5c55\u793a\u4e00\u4e2a\u4f7f\u7528\u5faa\u73af\u7684\u793a\u4f8b\u3002 <code inline=\"\">\u4e3a\u4e86<\/code> \u6211\u4eec\u7814\u7a76\u4e86\u5982\u4f55\u5c06\u4e00\u4e2a\u5305\u542b 10 \u4ebf\u4e2a\u6570\u5b57\u7684 Python \u5217\u8868\u4e2d\u7684\u6240\u6709\u5143\u7d20\u76f8\u52a0\uff0c\u5e76\u6bd4\u8f83\u4e86\u58f0\u660e\u53d8\u91cf\u548c\u4e0d\u58f0\u660e\u53d8\u91cf\u4e24\u79cd\u60c5\u51b5\u4e0b\u7684\u6267\u884c\u65f6\u95f4\u3002\u7eaf Python \u5b9e\u73b0\u8fd9\u4e2a\u8fc7\u7a0b\u9700\u8981\u8fd1\u4e24\u5206\u949f\uff0c\u800c\u4f7f\u7528 Cython \u5e76\u58f0\u660e\u9759\u6001\u53d8\u91cf\u540e\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u51e0\u4e4e\u77ac\u95f4\u5b8c\u6210\u3002.<\/p>","protected":false},"excerpt":{"rendered":"\u5f15\u8a00\uff1aPython \u53ef\u80fd\u662f\u5f53\u4eca\u6700\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\u4e4b\u4e00\uff0c\u4f46\u5b83\u7edd\u5bf9\u4e0d\u662f\u6700\u9ad8\u6548\u7684\u3002\u5c24\u5176\u662f\u5728\u2026\u2026\u9886\u57df\u3002","protected":false},"author":1,"featured_media":16513,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"\u0628\u0647\u06cc\u0646\u0647\u200c\u0633\u0627\u0632\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","_yoast_wpseo_canonical":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_opengraph-image":"","_yoast_wpseo_twitter-description":"","_yoast_wpseo_twitter-image":"","_yoast_wpseo_focuskeywords":"[]","_yoast_wpseo_primary_category":"193","footnotes":""},"categories":[193,363],"tags":[376],"class_list":{"0":"post-16496","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials","8":"category-programming","9":"tag-python"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran<\/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.itpiran.net\/blog\/zh\/tutorials\/boosting-python-scripts-cython\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"og:description\" content=\"\u0645\u0642\u062f\u0645\u0647 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0645\u0645\u06a9\u0646 \u0627\u0633\u062a \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u062d\u0628\u0648\u0628\u200c\u062a\u0631\u06cc\u0646 \u0632\u0628\u0627\u0646\u200c\u0647\u0627\u06cc \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc \u0627\u0645\u0631\u0648\u0632\u06cc \u0628\u0627\u0634\u062f\u060c \u0627\u0645\u0627 \u0642\u0637\u0639\u0627\u064b \u06a9\u0627\u0631\u0622\u0645\u062f\u062a\u0631\u06cc\u0646 \u0646\u06cc\u0633\u062a. \u0628\u0647\u200c\u0648\u06cc\u0698\u0647 \u062f\u0631 \u062f\u0646\u06cc\u0627\u06cc&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/boosting-python-scripts-cython\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-09T16:21:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.itpiran.net\/2024\/12\/09195033\/python-to-sython.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1793\" \/>\n\t<meta property=\"og:image:height\" content=\"1110\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"20 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\"},\"headline\":\"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646\",\"datePublished\":\"2024-12-09T16:21:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/\"},\"wordCount\":207,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/09195033\\\/python-to-sython.jpg\",\"keywords\":[\"Python\"],\"articleSection\":[\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/\",\"name\":\"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/09195033\\\/python-to-sython.jpg\",\"datePublished\":\"2024-12-09T16:21:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#primaryimage\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/09195033\\\/python-to-sython.jpg\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/12\\\/09195033\\\/python-to-sython.jpg\",\"width\":1793,\"height\":1110},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/boosting-python-scripts-cython\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/category\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"name\":\"\u0628\u0644\u0627\u06af ITPiran\",\"description\":\"\u0627\u062e\u0628\u0627\u0631 \u0648 \u0645\u0642\u0627\u0644\u0627\u062a \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\",\"name\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"alternateName\":\"ITPIran Blog\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"width\":512,\"height\":512,\"caption\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\",\"name\":\"admin\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/zh\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528 Cython \u6539\u8fdb Python \u811a\u672c - ITPiran \u535a\u5ba2","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.itpiran.net\/blog\/zh\/tutorials\/boosting-python-scripts-cython\/","og_locale":"zh_CN","og_type":"article","og_title":"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646 - \u0628\u0644\u0627\u06af ITPiran","og_description":"\u0645\u0642\u062f\u0645\u0647 \u067e\u0627\u06cc\u062a\u0648\u0646 \u0645\u0645\u06a9\u0646 \u0627\u0633\u062a \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u062d\u0628\u0648\u0628\u200c\u062a\u0631\u06cc\u0646 \u0632\u0628\u0627\u0646\u200c\u0647\u0627\u06cc \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc \u0627\u0645\u0631\u0648\u0632\u06cc \u0628\u0627\u0634\u062f\u060c \u0627\u0645\u0627 \u0642\u0637\u0639\u0627\u064b \u06a9\u0627\u0631\u0622\u0645\u062f\u062a\u0631\u06cc\u0646 \u0646\u06cc\u0633\u062a. \u0628\u0647\u200c\u0648\u06cc\u0698\u0647 \u062f\u0631 \u062f\u0646\u06cc\u0627\u06cc&hellip;","og_url":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/boosting-python-scripts-cython\/","og_site_name":"\u0628\u0644\u0627\u06af ITPiran","article_published_time":"2024-12-09T16:21:44+00:00","og_image":[{"width":1793,"height":1110,"url":"https:\/\/cdn.itpiran.net\/2024\/12\/09195033\/python-to-sython.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"20 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#article","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/"},"author":{"name":"admin","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81"},"headline":"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646","datePublished":"2024-12-09T16:21:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/"},"wordCount":207,"commentCount":0,"publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/12\/09195033\/python-to-sython.jpg","keywords":["Python"],"articleSection":["\u0622\u0645\u0648\u0632\u0634\u06cc","\u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/","url":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/","name":"\u4f7f\u7528 Cython \u6539\u8fdb Python \u811a\u672c - ITPiran \u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#primaryimage"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/12\/09195033\/python-to-sython.jpg","datePublished":"2024-12-09T16:21:44+00:00","breadcrumb":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#primaryimage","url":"https:\/\/cdn.itpiran.net\/2024\/12\/09195033\/python-to-sython.jpg","contentUrl":"https:\/\/cdn.itpiran.net\/2024\/12\/09195033\/python-to-sython.jpg","width":1793,"height":1110},{"@type":"BreadcrumbList","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/boosting-python-scripts-cython\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.itpiran.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u0622\u0645\u0648\u0632\u0634\u06cc","item":"https:\/\/www.itpiran.net\/blog\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"\u0628\u0647\u0628\u0648\u062f \u0627\u0633\u06a9\u0631\u06cc\u067e\u062a\u200c\u0647\u0627\u06cc \u067e\u0627\u06cc\u062a\u0648\u0646 \u0628\u0627 \u0633\u0627\u06cc\u062b\u0648\u0646"}]},{"@type":"WebSite","@id":"https:\/\/www.itpiran.net\/blog\/#website","url":"https:\/\/www.itpiran.net\/blog\/","name":"ITPiran\u535a\u5ba2","description":"\u4f0a\u6717\u53ef\u6301\u7eed\u8d38\u6613\u65b0\u95fb\u548c\u6587\u7ae0","publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.itpiran.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Organization","@id":"https:\/\/www.itpiran.net\/blog\/#organization","name":"\u4f0a\u6717\u53ef\u6301\u7eed\u5546\u4e1a\u535a\u5ba2","alternateName":"ITPIran Blog","url":"https:\/\/www.itpiran.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","contentUrl":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","width":512,"height":512,"caption":"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81","name":"\u884c\u653f","url":"https:\/\/www.itpiran.net\/blog\/zh\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/16496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/comments?post=16496"}],"version-history":[{"count":1,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/16496\/revisions"}],"predecessor-version":[{"id":16514,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/16496\/revisions\/16514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/media\/16513"}],"wp:attachment":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/media?parent=16496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/categories?post=16496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/tags?post=16496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}