Hacker News new | ask | show | jobs
by dr_zoidberg 3303 days ago
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.

1 comments

Just noticed after a while: it was "in the stack, not heap" (about the arrays).