3 ms·
PyPy also manages to speed this program up (or at least, what I understand this program to be): Alexanders-MacBook-Pro:tmp alex_gaynor$ time python t.py
by kingkilr 13y ago
PyPy also manages to speed this program up (or at least, what I understand this program to be):
Alexanders-MacBook-Pro:tmp alex_gaynor$ time python t.py
.
real 0m0.202s
user 0m0.194s
sys 0m0.007s
Alexanders-MacBook-Pro:tmp alex_gaynor$ time python t.py
.
real 0m0.192s
user 0m0.184s
sys 0m0.008s
Alexanders-MacBook-Pro:tmp alex_gaynor$ time python t.py
.
real 0m0.198s
user 0m0.190s
sys 0m0.007s
Alexanders-MacBook-Pro:tmp alex_gaynor$ time pypy t.py
.
real 0m0.083s
user 0m0.068s
sys 0m0.013s
Alexanders-MacBook-Pro:tmp alex_gaynor$ time pypy t.py
.
real 0m0.083s
user 0m0.068s
sys 0m0.013s
Alexanders-MacBook-Pro:tmp alex_gaynor$ time pypy t.py
.
real 0m0.082s
user 0m0.067s
sys 0m0.013s
Alexanders-MacBook-Pro:tmp alex_gaynor$ cat t.py
def main():
vals = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"}
for v in vals:
for w in vals:
for x in vals:
for y in vals:
for z in vals:
if v + w + x + y + z == "abcde":
print(".")
main()
- akx 13y agoThat's not the same program. You're using a set literal ({}) instead of a list ([]) or a tuple (()).
- dagw 13y agoJust tried it. Using a list instead of a set literal sped up the program slightly (~350 ms -> ~330 ms for python and ~155 ms -> ~140 ms for pypy on my computer).
- deleted 13y ago[deleted]
- hnriot 13y agowow, so much faster than lua
- kingkilr 13y agoYou can't compare measurements taken on different computers, for all you know the OP has a potato and I have a speed demon toaster.
- mistercow 13y agoDon't knock potatoes. I do all of my hardcore data analysis on my Very Large Potato Array.
- dagw 13y agoThey probably don't have the same hardware. On the same hardware I get: lua 5.1.5: ~480 ms python 2.7.5: ~330 ms luajit 2.0.2: ~190 ms pypy 2.0.2: ~140ms
- Zash 13y agoSame programs, same computer: ~$ time python t.py . real 0m0.350s user 0m0.304s sys 0m0.024s ~$ time lua t.lua . real 0m0.255s user 0m0.248s sys 0m0.004s ~$ time luajit t.lua . real 0m0.157s user 0m0.144s sys 0m0.012s
- haberman 13y agoI unfortunately had to edit the program after I took the measurements because HN cut off my program horizontally. So I removed one or two letters from the list.
- ahoge 13y agoI recommend to use a set of toy programs like those from the Benchmarks Game. Some nested loops with a little bit of string concatenation won't really tell you anything useful.