On 2 Feb., 16:35, Gregory Petrosyan <gregory.petros...@gmail.com> wrote:
> Clojure rev. 1173: > user=> (defn fac [#^Integer n] (reduce * (range 1 (+ 1 n)))) > #'user/fac > user=> (time (reduce + (map fac (range 1000)))) > "Elapsed time: 944.798019 msecs" > > Python 3.0:>>> import timeit > >>> t=timeit.Timer('sum(fac(n) for n in range(1000))', 'from functools import > >>> reduce; from operator import mul; fac = lambda n: reduce(mul, range(1, > >>> n+1), 1)') > >>> t.timeit(10)/10 > > 0.35052159800038679 > > This is XP SP2 on Core2 Duo, with 3Gb of RAM. > > As you can see, Python is almost 3 times faster on this > microbenchmark! Can anybody explain this to me? (No flame wars, > please, I am really interested in why the things are as they are, is > it considered ok or not, and what can be done to make Clojure faster > on similar tests). Hi, welcome in the group. Can you please write that program in Java and see how well it performs for you? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---