度确实没有C或者Java快
作者:互联网
Python的运行速度确实没有C或者Java快,但是有一些项目正在努力让Python变得更快。
Python代码简洁干净,但是大家都知道Python运行起来相对较慢 --- 在CPU密集型的任务上慢于C、Java和Javascript(但是大多数服务都不是CPU密集型的)--- 但是有些团队希望Python是尽善尽美的,所以他们准备从内而外地提升Python的性能。
如果你想让Python在特定硬件上运行得快一点,你至少有两个选择,每个选择都有一些弊病:
a. 你可以创建一个Python运行时的替代品,但是最后你会发现你重写了一遍CPython。
b. 你可以重写现存的部分代码来利用一些性能优化的特性,缺点是程序员需要做更多的工作。
下面是五种已有的方案,帮助你提高Python的性能。
PyPy
在CPython的替代品中,PyPy是最显眼的那一个(比如Quora就在生产环境中使用它)。它也最有机会成为默认解释器,它和现存Python代码高度兼容。
PyPy使用适时编译来加速Python,这项技术Google也在使用,Google在V8引擎中使用它加速Javascript。最近的版本PyPy2.5增加了一些提升性能的特性,其中有一项很受欢迎,它集成了Numpy,Numpy之前也一直被用来加速Python的运行。
使用Python3的代码需要对应地使用PyPy3。PyPy目前只支持到Python3.2.5,对Python3.3的支持正在进行中。
Pyston
Pyston,由Dropbox资助,使用LLVM编译器架构来加速Python,同样的它也使用了适时编译。相比于PyPy,Pyston还处于早期阶段,它只支持Python的部分特性。Pyston把工作分成两个部分,一部分是语言的核心特性,另一部分是把性能提升到可接受的程度。Pyston距离可以在生产环境使用还有一段距离
https://weibo.com/p/2313474633261539459150/wenda_home
https://weibo.com/p/2313474633261589791348/wenda_home
https://weibo.com/p/2313474633261644316796/wenda_home
https://weibo.com/p/2313474633261694386253/wenda_home
https://weibo.com/p/2313474633261749174533/wenda_home
https://weibo.com/p/2313474633261812088974/wenda_home
https://weibo.com/ttwenda/p/publisher3in1#/free
https://weibo.com/p/2313474633268208402711/wenda_home
https://weibo.com/p/2313474633268279443843/wenda_home
https://weibo.com/p/2313474633268355203468/wenda_home
https://weibo.com/p/2313474633268422049829/wenda_home
https://weibo.com/p/2313474633268493615245/wenda_home
https://weibo.com/p/2313474633268564918788/wenda_home
https://weibo.com/p/2313474633268636221586/wenda_home
https://weibo.com/p/2313474633268711719480/wenda_home
https://weibo.com/p/2313474633268795605375/wenda_home
https://weibo.com/p/2313474633268866908373/wenda_home
https://weibo.com/p/2313474633268942405668/wenda_home
https://weibo.com/p/2313474633269017903142/wenda_home
https://weibo.com/p/2313474633269076361495/wenda_home
https://weibo.com/p/2313474633269143732380/wenda_home
https://weibo.com/p/2313474633269206647039/wenda_home
https://weibo.com/p/2313474633269277687977/wenda_home
https://weibo.com/p/2313474633269349253356/wenda_home
https://weibo.com/p/2313474633269428682811/wenda_home
https://weibo.com/p/2313474633269496054310/wenda_home
https://weibo.com/p/2313474633269558706503/wenda_home
https://weibo.com/p/2313474633269630271579/wenda_home
https://weibo.com/p/2313474633269697380490/wenda_home
https://weibo.com/p/2313474633269764489315/wenda_home
https://weibo.com/p/2313474633269835530251/wenda_home
https://weibo.com/p/2313474633269902901750/wenda_home
https://weibo.com/p/2313474633269970010146/wenda_home
https://weibo.com/p/2313474633270041313454/wenda_home
https://weibo.com/p/2313474633270108422165/wenda_home
https://weibo.com/p/2313474633270179725377/wenda_home
https://weibo.com/p/2313474633270246834473/wenda_home
标签:weibo,Java,或者,Python,PyPy,homehttps,wenda,确实,com 来源: https://www.cnblogs.com/lubbre/p/14732331.html