O'Reilly logo

Learning Cython Programming by Philip Herron

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

Python bindings

Creating bindings to different native libraries is basically what we've been doing since the start, but it's good to iterate on how easy this can be for already-installed libraries.

When making bindings to projects, you must spend time analyzing the headers that you include in normal C applications. Once you do this, you're 80 percent of the way there. If you want, you can directly copy and implement the headers as a .pxd file and then just write Cython wrappers.

Although this approach is very formal and correct, it isn't really that helpful since you might as well just use C—and it doesn't even vaguely feel Pythonic. I would recommend writing wrapper functions that call the functions you care about yourself, making the library much ...

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