1. 程式人生 > >如何使用Psyco為你的Python程式提速

如何使用Psyco為你的Python程式提速

psyco加速Python執行速度的方法:
要求:

版本對照:
File name      Python versions      Well-tested with
psyco-x.y-win32-py2.2.2.exe     2.2.2 and up     2.2.2 and 2.2.3
psyco-x.y-win32-py2.3.exe     2.3 and up     2.3 and 2.3.3
psyco-x.y-win32-py2.4.exe     2.4 and up     2.4.*
psyco-x.y-win32-py2.5.exe     2.5 and up     2.4

作業系統,CPU的限制:
# A 32-bit architecture. A Pentium or any other Intel 386 compatible processor is recommended.

# Linux, Mac OS/X, Windows, BSD are known to work.

# A regular Python installation, version 2.2.2 or up. Psyco is not a replacement for the Python interpreter and

libraries, it works on top of them.

使用psyco
import psyco
psyco.full()#對所有函式用psyco進行編譯
psyco.bind(myfunction1)#對選中的函式用psyco進行編譯

g = psyco.proxy(f) #對函式f用psyco進行編譯
g(args)            # Psyco-accelerated call 編譯後g函式速度會有提升
f(args)            # regular slow call f函式保持原來的呼叫速度


psyco.log # 用來記錄日誌 Enable logging to a file named xxx.log-psyco by default, where xxx is the name of the

script you ran.

psyco.profile() # 可以替代psyco.ful()


psyco.log()
psyco.full(memory=100) #引數是什麼意思沒看懂。
psyco.profile(0.05, memory=100)#0.05,memeoy=100 引數也沒看懂。
psyco.profile(0.2)

參考:http://psyco.sourceforge.net/psycoguide/index.html psyco的使用說明書。

轉載自 :http://biansutao.iteye.com/blog/352394
---------------------
作者:longzhiwen888
來源:CSDN
原文:https://blog.csdn.net/longzhiwen888/article/details/46562665
版權宣告:本文為博主原創文章,轉載請附上博文連結!