4 ms·
Most fellow python people know this already, but native compiled C/C++ code generally runs about 100x faster than interpreted CPython code for any kind of numbe
by QuadrupleA 10y ago
Most fellow python people know this already, but native compiled C/C++ code generally runs about 100x faster than interpreted CPython code for any kind of number crunching or computation. So like sonium also mentioned, definitely consider the C route also if you're at all familiar with it and you're having performance problems. Threading python wouldn't generally get you as far (perhaps 4-6x speedup on an 8 core machine). Python's C integration is very well thought out and lets you use the best of both languages, as well as gain a deep understanding of what's going on under the hood in your python programs.
- hackermailman 10y agoThis is a good intro to Parallel Computing in C++ if anybody is interested http://www.cs.cmu.edu/~15210/pasl.html http://www.cs.cmu.edu/~15210/pasl.html I also liked this book http://www.parallel-algorithms-book.com/ http://www.parallel-algorithms-book.com/ (free draft copy) it identifies which algorithms are best candidates for running in parallel/divide and conquer strategy, like the analysis on MergeSort vs Quicksort.
- piker 10y agoForgive my ignorance, but how are you getting 4-6x speedup with threading in the face of the GIL? Asking because I generally choose C/C++ when performance matters over Python because of the GIL (and somewhat, the GC).
- brianwawok 10y agoWell you can multiproccess. 8 core machine? Run 8 pythons with 8 Gils. What web servers have done forever.
- piker 10y agoTrue, but OP said threading. Threading and multiprocessing imply significantly different engineering challenges.
- QuadrupleA 10y agoApparently the PP module here overcomes the GIL limitations, so I'm assuming you'd see a typical multithreading perf increase with it. Haven't tested it myself though.