News for hackers. Stuff that matters.
Re:Imperative Haskell by flavio81 on Wednesday May 31, 2017 @04:05AM (#14451020)
Python (in its CPython) incarnation is pretty slow usually. You can use PyPy (a JIT implementation of most of the Python spec) for dramatically more speed, but the code needs to be ported to work under PyPy.

The real comparison should be a language that is both functional and imperative and that allows you to write as brief a source code as you can do in Haskell.

Such a language is Common Lisp, and it will compile directly to machine language doing many optimizations.

Re:Imperative Haskell by masklinn on Wednesday May 31, 2017 @04:34AM (#14451096)
> the code needs to be ported to work under PyPy.

The only incompatibility is the `.copy()` calls which should be replaced by `list(contents)`, then it'll be cross-compatible between P2 and P3.

Here's what I get with that (on a 2010 MBP) using the random generation of lgas above (1M random ints):

    > time python2.7 qs.py
    python2.7 qs.py  41.92s user 0.37s system 98% cpu 42.837 total
    > time python3.6 qs.py
    python3.6 qs.py  42.99s user 0.32s system 98% cpu 44.047 total
    > time pypy qs.py
    pypy qs.py  3.27s user 0.12s system 94% cpu 3.603 total
There's a fair bit of variation but pypy is between 3.4 and 4
Re:Imperative Haskell by Veedrac on Wednesday May 31, 2017 @06:27PM (#14456434)
PyPy supports Python 3, so you don't need to port it at all.