[Python-Dev] Feature request: better support for "wrapper" objects

Jack Jansen jack@oratrix.nl
Sun, 06 Jan 2002 23:19:04 +0100


Something I've wanted for a long time, and maybe I should drop the
idea now.

There's a lot of Python objects that are really little more than
wrappers around an opaque C pointer (plus all the methods to operate
on it, etc). These objects usually have accompanying Parse() and
Build() functions, that you pass to the O& format for PyArg_Parse and
Py_BuildValue.

This all works fine, but I think we can do one better. If we have
slots in the type structure to store the Parse and Build functions we
could add a new format specifier O@ (or whatever other character is
free:-) that has a typeobject parameter and a C pointer
parameter. One advantage is that this would fit a lot better with the
new class inheritance scheme. Moreover, and more importantly, this
would give us a handle to use from Python code, so structmodule could
(un)pack structures that contain pointers to objects that are
python-wrappable, calldll could neatly wrap functions that have
python-wrappable objects, etc. 

Is this a good idea?
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma Goldman -