News for hackers. Stuff that matters.
Re:How fast can we make interpreted Python? (2013) by coryrc on Monday April 18, 2016 @04:53PM (#11523074)
My conclusion is: as long as you don't do anything new, Python is fast enough.
Re:How fast can we make interpreted Python? (2013) by ProblemFactory on Tuesday April 19, 2016 @02:45PM (#11529182)
That's true, but most of the time you can express the "new" stuff in terms of existing fast libraries.

I've had a few cases where you can't, and have become a big fan of Cython for that. It lets you add C typedefs to Python code, and then compile the module at import time. Example here: http://pastebin.com/sF8KmyiU

All of pure Python is still allowed in these modules, but the typedeffed variables become pure C variables instead of objects, and loops become pure C loops. For this particular function, I got a 1000x speedup compared to the original Python code.

In the end, this isn't Python any more - but it's close enough, and only needed for loops that run over millions of items.