<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Guido van Rossum wrote:
<blockquote
 cite="mid:ca471dc20904021019y66c44938n97ac9db677995249@mail.gmail.com"
 type="cite">
  <pre wrap="">On Thu, Apr 2, 2009 at 6:22 AM, Jim Fulton <a class="moz-txt-link-rfc2396E" href="mailto:jim@zope.com">&lt;jim@zope.com&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">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.
    </pre>
  </blockquote>
  <pre wrap=""><!---->I consider this the *only* use case. What other use cases are there?</pre>
</blockquote>
<br>
Exporting a C/C++ data structure:<br>
<blockquote><a class="moz-txt-link-freetext" href="http://wiki.cacr.caltech.edu/danse/index.php/Lots_more_details_on_writing_wrappers">http://wiki.cacr.caltech.edu/danse/index.php/Lots_more_details_on_writing_wrappers</a><br>
<a class="moz-txt-link-freetext" href="http://www.cacr.caltech.edu/projects/ARCS/array_kluge/array_klugemodule/html/misc_8h.html">http://www.cacr.caltech.edu/projects/ARCS/array_kluge/array_klugemodule/html/misc_8h.html</a><br>
<a class="moz-txt-link-freetext" href="http://svn.xiph.org/trunk/vorbisfile-python/vorbisfile.c">http://svn.xiph.org/trunk/vorbisfile-python/vorbisfile.c</a><br>
</blockquote>
Some folks don't register a proper type; they just wrap their objects
in CObjects and add module methods.<br>
<br>
The "obscure" method in the "Robin" package (
<a class="moz-txt-link-freetext" href="http://code.google.com/p/robin/">http://code.google.com/p/robin/</a> ) curiously wraps a *Python* object in
a CObject:<br>
<blockquote><a class="moz-txt-link-freetext" href="http://code.google.com/p/robin/source/browse/trunk/src/robin/frontends/python/module.cc">http://code.google.com/p/robin/source/browse/trunk/src/robin/frontends/python/module.cc</a><br>
</blockquote>
I must admit I don't understand why this is a good idea.<br>
<br>
<br>
There are many more wild &amp; wooly use cases to be found if you
Google for "PyCObject_FromVoidPtr".&nbsp; Using CObject to exporting C APIs
seems to be the minority, outside the CPython sources anyway.<br>
<br>
<br>
/larry/
</body>
</html>