Writing a wrapper - any tips?
Martin P. Hellwig
martin.hellwig at gmail.com
Fri Jul 13 09:39:32 CEST 2012
On Friday, 13 July 2012 05:03:23 UTC+1, Temia Eszteri wrote:
> I'm going to be looking into writing a wrapper for the Allegro 5 game
> development libraries, either with ctypes or Cython. They technically
> have a basic 1:1 ctypes wrapper currently, but I wanted to make
> something more pythonic, because it'd be next to impossible to deal
> with the memory management cleanly in the script itself.
> Anything I should keep in mind? Any tips to pass on to a first-time
> module writer, pitfalls to watch out for, etc.?
I would split the wrapping in layers, the lowest layer is a one on one exposure of the library with your wrapper, I would rather avoid ctypes for performance reasons, however if performance is not a concern ctypes is excellent and broadly available.
The next layer is purely there to make the lower layer pythonic, i.e. apply namespaces, automatic handling of memory, PEP8 naming convetions, etc. etc.
just what you would expect from a modern pure python module
The next layer, if you want to, contains tools that are often used in that concept, think in the line of design patterns.
More information about the Python-list