3 ms·
Typical speed difference between Python and native is around two orders of magnitude (of course for code that actually does computation in Python, not just call
by mmoskal 2y ago
Typical speed difference between Python and native is around two orders of magnitude (of course for code that actually does computation in Python, not just call numpy etc).
- fire_lake 2y agoIt can actually be way more than that for some applications - I found 1000x for some algorithm heavy use cases. I don’t find Python ergonomic enough to justify the performance penalty.
- willseth 2y agoIme 2 orders of magnitude is closer to best case, assuming you have already made reasonable Python-based optimizations. But this problem has two components, function call overhead and conditionals. Moving the original logic into a compiled extension would eliminate a lot of interpreter overhead for function calls, but it would not eliminate the branchy code. His codegen eliminated both.
- IshKebab 2y agoNah 2 orders of magnitude is very typical when going from Python to a "fast" language like C++ or Rust.
- willseth 2y agoIt's pointless to argue what's "typical" when actual results are incredibly varied and specific to each operation. Also you didn't read the rest of my comment.
- IshKebab 2y agoThey're varied. But 2 orders of magnitude is typical. Sometimes it's 1, sometimes 3. Rarely 0 or 4. I did read the rest of your comment; I was just not responding to that part.