{"id":1676,"date":"2012-10-01T10:34:54","date_gmt":"2012-10-01T02:34:54","guid":{"rendered":"http:\/\/ellery.no-ip.info\/wp\/thinkingmore\/?p=1676"},"modified":"2012-10-01T10:39:44","modified_gmt":"2012-10-01T02:39:44","slug":"python-performance-enhancement-tips%e7%ad%86%e8%a8%98","status":"publish","type":"post","link":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/2012\/10\/python-performance-enhancement-tips%e7%ad%86%e8%a8%98\/","title":{"rendered":"Python Performance Enhancement Tips\u7b46\u8a18"},"content":{"rendered":"<p><iframe loading=\"lazy\" style=\"border: 1px solid #CCC; border-width: 1px 1px 0; margin-bottom: 5px;\" src=\"http:\/\/www.slideshare.net\/slideshow\/embed_code\/14511831\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" width=\"427\" height=\"356\"><\/iframe><\/p>\n<div style=\"margin-bottom: 5px;\"><strong> <a title=\"Performance Enhancement Tips\" href=\"http:\/\/www.slideshare.net\/tim518\/presentation-14511831\" target=\"_blank\">Performance Enhancement Tips<\/a> <\/strong> from <strong><a href=\"http:\/\/www.slideshare.net\/tim518\" target=\"_blank\">Tim Hsu<\/a><\/strong><\/div>\n<div style=\"margin-bottom: 5px;\">\u4ee5\u4e0b\u662f\u6458\u8981\uff1a<\/div>\n<ul>\n<li>python -m cProfile -s cumulative $1<\/li>\n<li>time \u6307\u4ee4<\/li>\n<li>\u7528 pypy \u8207 python \u5c0d\u6bd4\uff1atime python a.py \u8207 time pypy a.py<\/li>\n<li>\u53ef\u4ee5\u8003\u616e\u7d44\u5408\u61c9\u7528\uff0c\u4e00\u90e8\u4efd\u7528 pypy\uff0c\u4e00\u90e8\u4efd\u7528 python\uff0c\u56e0\u70ba pypy \u7121\u6cd5\u4f7f\u7528\u67d0\u4e9b\u6a21\u7d44\u3002<\/li>\n<li>thread \u6548\u80fd\u4e0d\u5f70\uff0c\u56e0\u70ba GIL \u7684\u95dc\u4fc2\uff0c\u5118\u91cf\u4f7f\u7528 multiprocessing module \u4f86\u4ee3\u66ff thread\u3002\u8981\u6ce8\u610f\u4e0d\u53ef\u4ee5\u4f7f\u7528\u51fd\u5f0f\u5167\u7684\u51fd\u5f0f\uff0c\u5426\u5247\u6703\u6709 Exception \u767c\u751f\uff0c\u53c3\u6578\u51fd\u5f0f\u8ddf\u56de\u50b3\u503c\u90fd\u8981\u662f pickable \u7684\u3002<\/li>\n<li>\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 gevent\uff1a<a href=\"http:\/\/blog.ez2learn.com\/2010\/07\/17\/talk-about-coroutine-and-gevent\/\">\u6dfa\u8ac7coroutine\u8207gevent<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Performance Enhancement Tips from Tim Hsu \u4ee5\u4e0b\u662f\u6458\u8981\uff1a python -m cProfile -s cumulative $1 time \u6307\u4ee4 \u7528 pypy \u8207 python \u5c0d\u6bd4\uff1atime python a.py \u8207 time pypy a.py \u53ef\u4ee5\u8003\u616e\u7d44\u5408\u61c9\u7528\uff0c\u4e00\u90e8\u4efd\u7528 pypy\uff0c\u4e00\u90e8\u4efd\u7528 python\uff0c\u56e0\u70ba pypy \u7121\u6cd5\u4f7f\u7528\u67d0\u4e9b\u6a21\u7d44\u3002 thread \u6548\u80fd\u4e0d\u5f70\uff0c\u56e0\u70ba GIL \u7684\u95dc\u4fc2\uff0c\u5118\u91cf\u4f7f\u7528 multiprocessing module \u4f86\u4ee3\u66ff thread\u3002\u8981\u6ce8\u610f\u4e0d\u53ef\u4ee5\u4f7f\u7528\u51fd\u5f0f\u5167\u7684\u51fd\u5f0f\uff0c\u5426\u5247\u6703\u6709 Exception \u767c\u751f\uff0c\u53c3\u6578\u51fd\u5f0f\u8ddf\u56de\u50b3\u503c\u90fd\u8981\u662f pickable \u7684\u3002 \u53ef\u4ee5\u8003\u616e\u4f7f\u7528 gevent\uff1a\u6dfa\u8ac7coroutine\u8207gevent &nbsp; &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[17],"tags":[],"class_list":["post-1676","post","type-post","status-publish","format-standard","hentry","category-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2MOxp-r2","_links":{"self":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/1676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/comments?post=1676"}],"version-history":[{"count":0,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/posts\/1676\/revisions"}],"wp:attachment":[{"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/media?parent=1676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/categories?post=1676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ellery.no-ip.info\/wp\/thinkingmore\/wp-json\/wp\/v2\/tags?post=1676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}