加速Python脚本 [英] speeding up Python script

查看:63
本文介绍了加速Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-----开始PGP签名消息-----

哈希:SHA1





我有一个1000行的python脚本,需要很长时间才能完成。运行六个内部''for''循环是




我已经在网上寻找加速进程的方法。 />

在这种情况下,Psyco将性能提高了3%左右,这还不够好。


如何才能显着提高速度?


我试图找到一些自动将Python转换为C的工具但

不能。由于我不知道C,我认为编织和PyInline for

示例都不在解决方案之内。


我正在使用Linux。


Luis

----- BEGIN PGP SIGNATURE -----

版本:GnuPG v1.2.4(GNU / Linux)

评论:将GnuPG与Thunderbird一起使用 - http:// enigmail。 mozdev.org


iD8DBQFCio0YHn4UHCY8rB8RAoe0AKC4rj / dxE2HGw4xtCMEmVGDgrGEEwCghO1r

+ Rkgx8j1BzD0Lxq / iPey23s =

= xv4O

----- END PGP SIGNATURE -----

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a 1000 line python script that takes many hours to finish. It is
running with six inside ''for'' loops.

I''ve searched the net for ways to speed up the proccess.

Psyco improves performance around 3% in this case which is not good enough.

How can I dramatically improve speed?

I tried to find some tool that converts Python to C automatically but
couldn''t. As I don''t know C, I think that weave and PyInline for
example are out of the solution.

I''m using Linux.

Luis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCio0YHn4UHCY8rB8RAoe0AKC4rj/dxE2HGw4xtCMEmVGDgrGEEwCghO1r
+Rkgx8j1BzD0Lxq/iPey23s=
=xv4O
-----END PGP SIGNATURE-----

推荐答案

没有看到任何代码,很难说,但这并不是一个疯狂的猜测

''循环中的六个''可以被更有效的方式取代;-)

Without seeing any code, it''s hard to tell, but it''s not a wild guess
that ''six inside for loops'' may be replaced by more efficient ways ;-)


您可能希望通过BDFL阅读本案例研究。

http://www.python.org/doc/essays/list2str.html


2005年5月17日星期二下午05:32,Luis P. Mendes写道:
You may want to read through this case study by the BDFL.

http://www.python.org/doc/essays/list2str.html

On Tuesday 17 May 2005 05:32 pm, Luis P. Mendes wrote:


我有一个1000行的python脚本,需要很长时间才能完成。它有六个内部''for'循环运行。

我已经在网上寻找加速过程的方法。

Psyco改进在这种情况下性能大约为3%,这还不够好。

如何才能显着提高速度?

我试图找到一些自动将Python转换为C的工具但<不可能。由于我不知道C,我认为编织和PyInline for
示例都不在解决方案之内。

我正在使用Linux。

Luis
Hi,

I have a 1000 line python script that takes many hours to finish. It is
running with six inside ''for'' loops.

I''ve searched the net for ways to speed up the proccess.

Psyco improves performance around 3% in this case which is not good enough.

How can I dramatically improve speed?

I tried to find some tool that converts Python to C automatically but
couldn''t. As I don''t know C, I think that weave and PyInline for
example are out of the solution.

I''m using Linux.

Luis




-

James Stroud

加州大学洛杉矶分校基因组学和蛋白质组学研究所

方框951570

洛杉矶,加利福尼亚州90095

http://www.jamesstroud.com/


" Luis P. Mendes" <卢*********** @ netvisaoXXX.pt>写道:
"Luis P. Mendes" <lu***********@netvisaoXXX.pt> writes:
-----开始PGP签名消息-----
哈希:SHA1


<我有一个1000行的python脚本需要花费很多时间才能完成。
它运行时带有六个''for''循环。

我在网上搜索过加速过程的方法。

Psyco在这种情况下将性能提高了3%左右,这还不够好。

如何才能大大提高速度?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a 1000 line python script that takes many hours to finish.
It is running with six inside ''for'' loops.

I''ve searched the net for ways to speed up the proccess.

Psyco improves performance around 3% in this case which is not good
enough.

How can I dramatically improve speed?




您正在寻找更好的算法,而不是Python优化。


-
http://www.peter.dembinski.prv.pl


这篇关于加速Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆