Re:PyPy v5.8 released
by dr_zoidberg on Friday June 09, 2017 @10:44AM
(#14521721)
The one time I saw 100x increase in performance in Python-to-C (which was done through Cython) was in code that worked with strings calculating a machine-learning related distance between two strings. The code was doing a lot of accessing particular positions in the strings, which in pure python resulted in slow retrieval of every character (lots of .__getitem__ calls), which were optimized to having 2 predefined empty arrays (in heap, not stack, and their corresponding counters of valid items) and then walking the strings and storing the "hot" values in them.
So it was a very specific case where we could get that 100x speedup at work.
Re:PyPy v5.8 released
by dr_zoidberg on Friday June 09, 2017 @03:25PM
(#14523745)
Just noticed after a while: it was "in the stack, not heap" (about the arrays).
Use numpy for matrices. If you have to implement an algo with a hot inner loop, use cython or numba.
I've never seen 100x difference in Python-C++ rewrite if Python was optimized already.
Here is a good article about some of the options: https://rare-technologies.com/word2vec-in-python-part-two-op...