ctypes

The ctypes library allows the developer to reach under the hood of Python and tap into the power of the C language. This is only possible with the official interpreter (CPython) because it is written in C. Other versions of it, such as PyPy or Jython, do not provide access to this library.

This interface to C can be used to do many things, since you literally have the ability to load pre-compiled code and use it from C. This means you have access to libraries such as kernel32.dll and msvcrt.dll for Windows systems, and libc.so.6 for Linux systems.

For our particular case, we'll focus on ways to optimize our code, showing how to load a custom C library and how to load a system library to take advantage of its optimized code. For full details ...

Get Mastering Python High Performance 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.