- 注册时间
- 2004-11-1
- 最后登录
- 2018-4-24
版主
  
- 积分
- 548
|

楼主 |
发表于 2007-11-23 17:26:02
|
显示全部楼层
http://programming.reddit.com/info/152lr/comments/c156v0- Just for those who want to check pypy out a bit:
- First download pypy, then run the translatorshell in the bin/ directory.
- $ python translatorshell.py
- *snip*
- >>> def ack(x,y):
- ... if x == 0: return y + 1
- ... elif y == 0: return ack(x - 1, 1)
- ... else: return ack(x - 1, ack(x, y - 1))
- ...
- >>> t = Translation(ack)
- >>> t.annotate([int, int])
- *snip*
- >>> t.rtype()
- *snip*
- >>> ack_c = t.compile_c()
- *snip*
- >>> import time
- >>> start = time.time(); ack(3,6); print time.time() - start
- 509
- 0.19878911972
- >>> start = time.time(); ack_c(3,6); print time.time() - start
- 509
- 0.00290894508362
- The C version is nearly 70 times faster than the pure python version.
- I do know that this is not the usual real life bottleneck that you run across, but it does somehow show PyPy's potential.
复制代码 |
|