We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

Writing C is hard; are there any alternatives?

There are a number of alternatives to writing your own C extensions, depending on what you’re trying to do.

If you need more speed, Psyco generates x86 assembly code from Python bytecode. You can use Psyco to compile the most time-critical functions in your code, and gain a significant improvement with very little effort, as long as you’re running on a machine with an x86-compatible processor.

Pyrex is a compiler that accepts a slightly modified form of Python and generates the corresponding C code. Pyrex makes it possible to write an extension without having to learn Python’s C API.

If you need to interface to some C library for which no Python extension currently exists, you can use the ctypes library, or wrap the library’s data types and functions with a tool such as SWIG.

For C++ libraries, see:

how-do-i-interface-to-c-objects-from-python

CATEGORY: extending