PyEmbedC

What is PyEmbedc?

PyEmbedC enables you to write hybrid Python programs that include short C/C++ snippets to improve performance or access special features of the OS.

Features

Background

This project grew from frustration. I wrote a simple program to solve a numerical problem in Python. But it was slow. It gathered some initial states, read data files, queried a few Web APIs, etc. That part was great. Python's flexibility was a huge asset. The slow part was just three nested loops that performed a calculations.

In order to achieve faster run tiimes, I had to rewrite the entire thing in C, which was a quite a pain, especially for the setup part involving parsing text, processing arrays and all the things that are painful in C, but wonderfully simple in Python. If only I could combine both.

In doing research, I learned of several related projects, none of which really worked. Some were older attempts that didn't work well with the current Python. Using ctypes was an excellent possibility, and is the basis of PyEmbedC. But it was still clumsy. I only needed to write 10 lines in C. Why force users to learn a new Python API, create a separate environment, with Makefiles, etc. for such a simple operation?

And thus, PyEmbedC was born.