[Python-Dev] Let's update CObject API so it is safe and regular!
hrvoje.niksic at avl.com
Thu Apr 2 14:42:44 CEST 2009
Greg Ewing wrote:
> Attaching some kind of type info to a CObject and having
> an easy way of checking it makes sense to me. If the
> existing CObject API can't be changed, maybe a new
> enhanced one could be added.
I thought the entire *point* of C object was that it's an opaque box
without any info whatsoever, except that which is known and shared by
its creator and its consumer.
If we're adding type information, then please make it a Python object
rather than a C string. That way the creator and the consumer can use a
richer API to query the "type", such as by calling its methods or by
inspecting it in some other way. Instead of comparing strings with
strcmp, it could use PyObject_RichCompareBool, which would allow a much
more flexible way to define "types". Using a PyObject also ensures that
the lifecycle of the attached "type" is managed by the well-understood
More information about the Python-Dev