4 ms·
Seems the lesson is that Python is slow. Author's realization about how to use it correctly was to just call C instead. Article not worth reading. Would have b
by adultSwim 11y ago
Seems the lesson is that Python is slow. Author's realization about how to use it correctly was to just call C instead.
Article not worth reading. Would have been much better as a quick tip. "Quick tip: if you need to loop through an array in Python, do it this way instead..."
- dekhn 11y agoActually, 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".
- deleted 11y ago[deleted]
- pacofvf 11y agoAnd even then C was not the appropriate tool for the job, Postgis would have been easier and maybe faster.
- chuckcode 11y agoAgree, non-informative article. If you're doing linear algebra, it is always a good idea to notice and then use a library. Even in c/c++ using eigen[1] or mkl[2] for speed and stability is a good idea when doing linear algebra. [1]http://eigen.tuxfamily.org/index.php?title=Main_Page http://eigen.tuxfamily.org/index.php?title=Main_Page [2]https://software.intel.com/en-us/intel-mkl https://software.intel.com/en-us/intel-mkl
- therobot24 11y agoI like eigen, but their documentation is very lacking (only contains basic usage and toy examples). However, this isn't what caused me to abandon the library, it was the lack of support for 3-dimensional matrices.
- chuckcode 11y agotherobot24 - What libraries do you like better? Eigen is my current favorite free linear algebra library but it doesn't have 3d matrices and doesn't support avx instructions which are both areas for improvement.
- therobot24 11y agoUnfortunately I wasn't able find one to best suit my needs so I ended up implementing a lot of the structure manually.
- bitwize 11y agoHow about: C Programmers Hate Her! Schoolteacher Discovers One Weird Trick to Speed Up Loops in Python