When correctly benchmarking 'while' and 'for' in Python and newLISP, I cannot see much of a difference.
Code: Select all
# while.py
i = 0;
while i < 10000000:
i = i + 1
# while.lsp
(setq i 0)
(while (< i 10000000)
(++ i 1))
(exit)
~/shootout> time python while.py
real 0m1.946s
user 0m1.924s
sys 0m0.019s
~/shootout> time newlisp while.lsp
real 0m2.591s
user 0m2.573s
sys 0m0.005s
Python about 33% faster using 'while'
Code: Select all
# for.py
i = 0;
for k in xrange(1, 10000000):
i = i + 1
# for.lsp
(set 'i 0)
(for (k 1 10000000)
(++ i 1))
(exit)
~/shootout> time python for.py
real 0m2.717s
user 0m2.696s
sys 0m0.019s
~/shootout> time newlisp for.lsp
real 0m1.712s
user 0m1.694s
sys 0m0.004s
newLISP 58% faster using 'for'
The difference you saw in your code was due to I/O speed difference for a simple 'print' statement with a short string. If you compare real world code examples, I/O speed between Python, Perl and newLISP, the difference is much smaller, Perl most of the time beeing the fastest, then Python then newLISP.
Ps: note that I am using 10,000,000 iterations instead of 1,000,000 to minimize the effect of newLISP's much faster startup time.