O'Reilly logo

Expert Python Programming - Second Edition by Tarek Ziadé, Michał Jaworski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Why you might want to use extensions

It's not easy to say when it is a reasonable decision to write extensions in C/C++. The general rule of thumb could be, never, unless you have no other choice. But this is a very subjective statement that leaves a lot of room for interpretation of what is not doable in Python. In fact, it is hard to find a thing that cannot be done using pure Python code, but there are some problems where extensions may be especially useful:

  • Bypassing GIL (Global Interpreter Lock) in the Python threading model
  • Improving performance in critical code sections
  • Integrating third-party dynamic libraries
  • Integrating source code written in different languages
  • Creating custom datatypes

For example, the core language constraints such as GIL ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required