3 ms·
That's not a great analogy. Haskell is a neat language in part because it doesn't have mutability. Python is a neat language despite being slow. I can't imagin
by jsharpe 8y ago
That's not a great analogy. Haskell is a neat language in part because it doesn't have mutability. Python is a neat language despite being slow.
I can't imagine anyone would object if Python could magically be 10x faster. I can't say the same thing for the Haskell thing.
- gnulinux 8y agoMy whole point is that 10x thing cannot just magically happen. The reason Python is slow is not incompetent programming or lack of magic. We know why that's happening. Because every variable in Python interpreter is a hash map and pretty much every operation is a hash map lookup. How do you optimize this? The only way is to remove language features like `setattr` and my whole point is that some people use Python because it's flexible enough to do that so they need their `setattr`.
- civility 8y ago> The reason Python is slow is not incompetent programming or lack of magic. We know why that's happening. Because every variable in Python interpreter is a hash map and pretty much every operation is a hash map lookup. This statement is easily refuted by PyPy. Here's a simple program which runs 70 times faster in PyPy than Python on my machine - including startup time: https://pastebin.com/2n0PL9hY > How do you optimize this? Semantically, everything in JavaScript and Lua is also hash map lookups. Yet very smart people have made those languages very fast. CPython is not slow for the reasons you stated.
- rrcaptain 8y agoNot all python programs are compatible with PyPy though. Nor do they get much of a performance boost by switching. Pandas and NumPy for example didn't work on PyPy until less than a year ago. And a good chunk of Python codebases are going to use one of those at some point.
- civility 8y ago> Not all python programs are compatible with PyPy though. I'm not sure how this is relevant to my reply... I didn't say PyPy was a replacement for Python. I said PyPy, Lua, and JavaScript are existence proofs that dynamic "hash table" languages don't have to be slow. Therefore, CPython must be slow for some other reason.
- mratsim 8y agoPypy can't accelerate the Pandas/Numpy part anyway, the computationally intensive code in Numpy and Pandas is coded in C, C++ or Fortran. Though there are a lot of if isInstance(Foo, bar) that could be avoided in a statically typed language.