3 ms·
Actually, in most cases, you can speed up loops in python knowing just a few tricks. https://wiki.python.org/moin/PythonSpeed/PerformanceTips https://wiki.pytho
by dekhn 11y ago
Actually, in most cases, you can speed up loops in python knowing just a few tricks.
https://wiki.python.org/moin/PythonSpeed/PerformanceTips https://wiki.python.org/moin/PythonSpeed/PerformanceTips
I see numerous issues with the loop, for example, hash key lookups on 'Lat' and 'Long' for every iteration.
- someone7x 11y agoExactly. Usually a first approach at speeding up a loop is to just make it a list comprehension. I feel it's more pythonic to optimize for readability first and performance as needed; is the author upset he didn't get both at the same time?
- rasz_pl 11y agoumm NO. Whats next, BasicPerformanceTips? Its an interpreted language, it will always be at least 10x slower. Great for prototyping, bad for serious work.
- e12e 11y agoSure. Quick performance tip for basic, use a complied dialect, like Blitz Basic (now, not quite just BASIC, and called Blitz).
- mikeash 11y agoThere are a lot of problems where a 10x speed hit is totally fine, but a 100x speed hit is unacceptable. In cases like that, knowing how to make your interpreted code go faster can be really useful.
- outworlder 11y agoThere is no such thing as an "interpreted language", there are only implementations. Please get rid of these old concepts. CPython, which is the standard, most common implementation, uses bytecodes (and so does Java). There's nothing preventing one from generating machine code from a Python source. Some of Python's dynamic features are mandated from the spec, and there are limits on how fast that can be. But that has nothing to do with "being an interpreted language".