Live data from Hacker News

Python’s Weak Performance Matters

metarabbit.wordpress.com

1–10 of 336 posts

Re: Python’s Weak Performance Matters

#2
> The result is that I find myself doing more and more things in Haskell, which lets me write high-level code with decent performance (still slower than what I get if I go all the way down to C++, but with very good libraries).

This strikes me as an odd conclusion to come to if speed was the main motivator.

Re: Python’s Weak Performance Matters

#4

> The result is that I find myself doing more and more things in Haskell, which lets me write high-level code with decent performance (still slower than what I get if I go all the way down to C++, but with very good libraries). This strikes me as an odd conclusion to come to if speed was the main motivator.

How so? Haskell has a very high performance ceiling.

Re: Python’s Weak Performance Matters

#5
Something I often wonder in these sort of discussions is why C# is generally omitted. Its performance is comparable to C++, with none of the trappings. It also does an excellent job of integrating some of the most useful features of functional programming into an imperative language. And multi-processor programming with the language is also incredibly simple.

But I think the best part is in programmer time. An anecdote I find endlessly entertaining is on another forum I shared some code to solve a problem people were having an issue with, and it was assumed my code was pseudo-code. It was correct, compilable C#. And they're constantly adding incredibly useful features. For instance a recent addition is more expressive tuples:

    (int number, string s, char c) triple = (2, "two", '2');
    triple.number = 13;
And lambda functionality is similarly clean. A lambda value might be:

    x => 2*x + 5;
Equivalently, as an anonymous method:

    delegate(double x){return 2*x + 5;}
And an example of how simple arbitrary processor count parallel programming can be (using lambda syntax as above):

    Parallel.ForEach(listOfThings, thing => DoSomething(thing));

Yet as typical in scenarios like this one, the author sees the decision as being between opposite extremes of C++ and Python. The only downsides of the language I've run into are a lack of some shoot yourself in the foot features of C++, like multiple inheritance, and the fact that template specialization is awkward. Garbage collection is vastly overblown. My main work is with projects that have in memory collections in the gigs of size and you'd think the collector would be a huge issue, yet it's mostly transparent and can be controlled if necessary - which in the vast majority of cases, is not.

Re: Python’s Weak Performance Matters

#6

> The result is that I find myself doing more and more things in Haskell, which lets me write high-level code with decent performance (still slower than what I get if I go all the way down to C++, but with very good libraries). This strikes me as an odd conclusion to come to if speed was the main motivator.

Me too. I have heard from someone that used Haskell in production that lazy evaluation caused trouble in terms of achieving predictable performance.

Re: Python’s Weak Performance Matters

#7
I recently discovered that pypy3 can run all my day to day Python code. It has some issues with slightly different behavior from cpython when using threads but other than that I see a 4x speedup on most of my slowest pure python workloads (parsing large rdf files and reserializing them after computing a total order on all their nodes). Huge win for productivity.

Re: Python’s Weak Performance Matters

#8

> The result is that I find myself doing more and more things in Haskell, which lets me write high-level code with decent performance (still slower than what I get if I go all the way down to C++, but with very good libraries). This strikes me as an odd conclusion to come to if speed was the main motivator.

Not saying you're wrong - you definitely don't get great performance easily in Haskell, but it seems to have better benchmarks than python, by a lot.

Re: Python’s Weak Performance Matters

#9

> The result is that I find myself doing more and more things in Haskell, which lets me write high-level code with decent performance (still slower than what I get if I go all the way down to C++, but with very good libraries). This strikes me as an odd conclusion to come to if speed was the main motivator.

I read it as a compromise. I don’t think the author is primarily a programmer, but mainly uses high-level “easy” languages to do data science.

C++ would probably increases his development time significantly compared to Haskell.

Re: Python’s Weak Performance Matters

#10
There’s a project to plug different JIT compilers into CPython, so there’s hope. https://github.com/Microsoft/Pyjion/blob/master/README.md

Also, I’ve more than once seen cpython beat C++/Fortran since it’s easier to do the right algo/datastructure things, plus numpy is more optimized than most «amateur» C loop-over-arrays.

That being said, faster python is always welcome.

Post reply on HN