4 ms·
Performant code in the wild largely disagrees? This is the difference between a numpy array versus a regular python list. It is stark. You are correct that y
by taeric 2y ago
Performant code in the wild largely disagrees? This is the difference between a numpy array versus a regular python list. It is stark.
You are correct that you can often engineer the performance later. But layout concerns and nominal types for performance are fairly non controversial.
- thesz 2y agoPython does not do optimizations at all. In contrast, you can find Fortran compilers that can substitute your inefficient implementation of some numerical algorithm with different much more performant one.
- PaulHoule 2y agoPython has a peephole optimizer: https://akaptur.com/blog/2014/08/02/the-cpython-peephole-optimizer-and-you/ https://akaptur.com/blog/2014/08/02/the-cpython-peephole-opt...
- maccard 2y agoI think what OP meant was "Python's optimisations are not very fast", which (IMO) is a fair statement. Python is many, many things, but it's best case scenarios (without rewriting in C, at which point you're writing C not python) are slower than the naive implementations in many other languages.
- thesz 2y agoPython optimizations are not deep and/or broad. I did not mean "very fast" as in "compilation speed." Python does not attempt to apply anything more complex than that peephole optimizer, whatever that means. Judging from my experience with Python, that peephole optimizer cannot lift operations on "dictionary with default value" to a regular dictionary operations using conditionals. I had to manually rewrite my program to use conditionals to recover it's speed.