Guido van Rossum wrote:
On Thu, Apr 2, 2009 at 6:22 AM, Jim Fulton <j...@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/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to