前言
python哲學(xué)理念
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
1.python可定義為面向?qū)ο蟮哪_本語(yǔ)言
2.python的最大缺點(diǎn)是執(zhí)行速度不夠快
3.python可以被應(yīng)用于以下幾個(gè)方面:系統(tǒng)編程,用戶圖形接口,Internet腳本蜒秤,組件集成惠毁,數(shù)據(jù)庫(kù)編程灯蝴,快速原型颜骤,科學(xué)計(jì)算柔袁,游戲呆躲,圖像,人工智能捶索,XML插掂,機(jī)器人等。
4.python的優(yōu)點(diǎn):面向?qū)ο笮壤赓M(fèi)辅甥,可移植,功能強(qiáng)大燎竖,可混合璃弄,易學(xué)易用。
Python是如何運(yùn)行的
Python解釋器
Python解釋器一般是C實(shí)現(xiàn)的底瓣,也有用Java實(shí)現(xiàn)的Jython谢揪。
Python文件的執(zhí)行
1.Python的傳統(tǒng)運(yùn)行執(zhí)行模式:源代碼(.py)→字節(jié)碼(.pyc)→PVM
錄入的源代碼轉(zhuǎn)換為字節(jié)碼,之后字節(jié)碼在Python虛擬機(jī)(PVM)中運(yùn)行捐凭。代碼被自動(dòng)編譯拨扶,之后再解釋。
2.執(zhí)行優(yōu)化工具:
- Psyco實(shí)時(shí)編譯器:Psyco是一個(gè)PVM的增強(qiáng)工具茁肠,將部分程序的字節(jié)碼轉(zhuǎn)換成底層的真正的二進(jìn)制機(jī)器代碼
- Shedskin C++轉(zhuǎn)換器