Improving performance using Python extensions

One of the gripes of Python and pandas users is that the ease of use and expressiveness of the language and module comes with a significant downsidethe performance. This happens especially when it comes to numeric computing.

According to programming benchmark standards, Python is often slower than compiled languages, such as C/C++, for many algorithms or data structure operations. An example of this would be binary-tree operations. In one simulation experiment, Python3 ran 104 times slower than the fastest C++ implementation of an n-body simulation calculation.

So, how can we solve this legitimate, yet vexing problem? We can mitigate this slowness in Python while maintaining the things that we ...

Get Mastering pandas - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.