How to call and execute C code in Python?

Stefan Behnel stefan_ml at behnel.de
Sun May 13 13:38:55 EDT 2012


Mark Lawrence, 13.05.2012 19:23:
> On 13/05/2012 16:39, Chris Angelico wrote:
>> On Sun, May 13, 2012 at 11:25 PM, David Shi wrote:
>>> Can anyone tell me how to call and exectute C code in Python?
>>
>> Browse the documentation about Extending and Embedding Python, there's
>> an extensive API.
> 
> I like your response, my first thought was to say "yes" :)

It has a serious learning curve all by itself, though, with a lot of major
pitfalls not only for new users. It also requires C fluency, which not
everyone has or wants to learn just to be able to talk to existing C code.
And even when you're up to speed with all that, you will waste a
substantial part of your time debugging crashes, making your code reference
leak free and eventually maintaining it and porting it to different CPython
versions and platforms. Time that IMHO is much better spent adding features
and tuning the code for performance.

Stefan




More information about the Python-list mailing list