[Python-Dev] Let's update CObject API so it is safe and regular!
Larry Hastings
larry at hastings.org
Thu Apr 2 21:22:51 CEST 2009
Guido van Rossum wrote:
> On Thu, Apr 2, 2009 at 6:22 AM, Jim Fulton <jim at zope.com> wrote:
>
>> The original use case for CObjects was to export an API from a module, in
>> which case, you'd be importing the API from the module.
>>
> I consider this the *only* use case. What other use cases are there?
Exporting a C/C++ data structure:
http://wiki.cacr.caltech.edu/danse/index.php/Lots_more_details_on_writing_wrappers
http://www.cacr.caltech.edu/projects/ARCS/array_kluge/array_klugemodule/html/misc_8h.html
http://svn.xiph.org/trunk/vorbisfile-python/vorbisfile.c
Some folks don't register a proper type; they just wrap their objects in
CObjects and add module methods.
The "obscure" method in the "Robin" package (
http://code.google.com/p/robin/ ) curiously wraps a *Python* object in a
CObject:
http://code.google.com/p/robin/source/browse/trunk/src/robin/frontends/python/module.cc
I must admit I don't understand why this is a good idea.
There are many more wild & wooly use cases to be found if you Google for
"PyCObject_FromVoidPtr". Using CObject to exporting C APIs seems to be
the minority, outside the CPython sources anyway.
/larry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090402/337d0fc0/attachment-0001.htm>
More information about the Python-Dev
mailing list