[Python-Dev] Let's update CObject API so it is safe and regular!

Guido van Rossum guido at python.org
Thu Apr 2 19:53:40 CEST 2009


On Thu, Apr 2, 2009 at 10:24 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Guido van Rossum <guido <at> python.org> writes:
>>
>> 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?
>
> I don't know if it is good style, but I could imagine it being used to
> accumulate non-PyObject data in a Python container (e.g. a list), without too
> much overhead.
>
> It is used in getargs.c to manage a list of "destructors" of temporarily created
> data for when a call to PyArg_Parse* fails.

Well, that sounds like it really just needs to manage a
variable-length array of void pointers, and using PyList and PyCObject
is just laziness (and perhaps the wrong kind -- I imagine I could
write the same code without using Python objects and it would be
cleaner *and* faster).

So no, I don't consider that a valid use case, or at least not one we
need to consider for backwards compatibility of the PyCObject design.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list