[Haskell-cafe] Efficient functional idiom for histogram
Ketil Malde
ketil at malde.org
Sat Aug 1 13:36:32 EDT 2009
Paul Moore <p.f.moore at gmail.com> writes:
> What am I doing wrong here? I'd have expected compiled Haskell to be
> faster than interpreted Python, so obviously my approach is wrong.
Two things from my experience: Python associative arrays are fast, and
Haskell random numbers are slow. So by building a map from random
numbers, you are likely doing a fairly pessimal comparison. Did you
profile to see where the time is spent?
> I'm expecting the answer to be that I've got unnecessary laziness
IME, laziness usually affects space, but not so much time
performance. Although 'insertWith (+)' looks like it would build
unevaluated thunks for the sums.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list