Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25253

Re: Writing a wrapper - any tips?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!216.196.98.142.MISMATCH!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From "Martin P. Hellwig" <martin.hellwig@gmail.com>
Newsgroups comp.lang.python
Subject Re: Writing a wrapper - any tips?
Date Fri, 13 Jul 2012 00:39:32 -0700 (PDT)
Organization http://groups.google.com
Lines 20
Message-ID <9a3fe09a-82dd-4623-a6da-15a23633db3b@googlegroups.com> (permalink)
References <d37vv7ds3s1sus5jr9cvn17gje775l3l4l@4ax.com>
NNTP-Posting-Host 178.78.117.54
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1342165172 4999 127.0.0.1 (13 Jul 2012 07:39:32 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Fri, 13 Jul 2012 07:39:32 +0000 (UTC)
In-Reply-To <d37vv7ds3s1sus5jr9cvn17gje775l3l4l@4ax.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=178.78.117.54; posting-account=tAClXAkAAAATLknY-9JB9wrc3DJg4qmL
User-Agent G2/1.0
Xref csiph.com comp.lang.python:25253

Show key headers only | View raw


On Friday, 13 July 2012 05:03:23 UTC+1, Temia Eszteri  wrote:
> I&#39;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&#39;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.?
<cut>
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.

hth
-- 
mph

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Writing a wrapper - any tips? Temia Eszteri <lamialily@cleverpun.com> - 2012-07-12 21:03 -0700
  Re: Writing a wrapper - any tips? "Martin P. Hellwig" <martin.hellwig@gmail.com> - 2012-07-13 00:39 -0700
    Re: Writing a wrapper - any tips? Stefan Behnel <stefan_ml@behnel.de> - 2012-07-13 11:49 +0200

csiph-web