[Tutor] Python Extensions in C

Stefan Behnel stefan_ml at behnel.de
Thu May 26 21:07:53 CEST 2011


Stefan Behnel, 26.05.2011 18:10:
> James Reynolds, 26.05.2011 17:22:
>> As an intellectual exercise, I wanted to try my hand at writing some
>> extensions in C.
>
> This is fine for en exercise, and I hope you had fun doing this.
>
> However, for real code, I suggest you use Cython instead. Your module would
> have been substantially simpler and likely also faster.
>
> http://cython.org

Oh, and one more thing: it makes it easier to write safe, portable and 
versatile code. As others have pointed out, your code has unnecessary bugs. 
It also doesn't compile in Python 3 and lacks the ability to calculate the 
averages of a set or deque, for example. Instead, it only handles tuples 
and lists. That reduces the usefulness of your implementation.

Stefan



More information about the Tutor mailing list