It wont solve your performance problem but I think that your python code 
translates to:

(defn f[a b c]
  (+ (* c c c c) (* b b b) (* a a)))

(count
  (into #{} 
    (for [c primes :while (< (f (first primes) (first primes) c) limit)
          b primes :while (< (f (first primes) b c) limit)
          a primes :let [x (f a b c)] :while (< x limit)]
      x)))


Could you run your tests with -XX:+PrintGCDetails passed to the jvm?

Christophe

tristan a écrit :
> Hi guys,
>
> I'm loving Clojure, but i'm having a lot of trouble writing programs
> in it that run as fast as my python equivalents.
> One example is code i've written for projecteuler.net problem 87 (for
> those who don't want to see any solutions don't click the links
> below :))
> my python version 
> http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1d5b5692f86f963c6bcc7b/0087.py
> runs in ~4 seconds (timed using cygwin "time python 0087.py" whereas
> my clojure version 
> http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1d5b5692f86f963c6bcc7b/0087.clj
> takes over 20 seconds (time gotten from (time call in the code). This
> is quite disheartening for me as well since i wrote the python version
> in about a minute and haven't even thought about optimizations yet. It
> was just written as a test since i was unhappy with the speed of my
> clojure version even after re-writing it a few times and shaving off
> about 20 seconds from my original.
>
> I'm sure there must be something i'm doing wrong, or thinking wrongly
> about hence why i'm not getting the speed i need. Can anyone suggest
> any alternate ways to write this? or anything to speed it up? I really
> enjoy programming in Clojure, but speed is starting to become an issue
> with me.
>
> Thanks
> -Tristan
> >
>
>   


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (en)



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to