[C++-sig] Re: Python API wrapping details

Dave Hawkes daveh at cadlink.com
Thu Jun 20 17:16:41 CEST 2002


"David Abrahams" <david.abrahams at rcn.com> wrote in message
news:0f8401c21867$9d4d9280$6601a8c0 at boostconsulting.com...
> > the API metadata will be defined in the python script. The python script
> > will then use a set of rules to generate the API wrappers from this
> > metadata.
>
> That sounds slower than just doing it by hand overall. The API isn't that
> big.
>

I think it will be less error prone this way, particularly if we find that
we want a large number of overloads of the same function.

> > overloaded functions so that either type of arg is acceptable?
>
> That's the approach I've been taking. It's not checked in yet, but I've
> overloaded the xxxattr() function to accept char const* keys.
>

OK

> > force the user to do an explicit &obj.
>
> This is an artifact of a C implementation; we should think about what
makes
> sense for C++, and mirror Python's interface:
>

Using that logic would mean that the vast majority of these functions should
really be members of object as their first parameter is invariably
PyObject*? Would you consider 'growing' the object declaration to include
the API?

> > 3) Should all functions always return an object (unless they are void)?
>
> Not neccessarily

OK

>
> > There may be efficiency concerns if we keep wrapping int returns all the
> > time.
>
> It depends how things are used. What functions did you have in mind?
>

Functions like PyObject_HasAttrString, but then, as above, this is so
commonly used maybe it should be a member anyway.

> > We could also provide versions of the functions that do either (though
> > we can't overload on return type). Some return types may not even be
> > appropriate to return as an object (ie FILE*).
>
> try:
>
>     >>> help(file)
>

Yes I know there is a PyFileObject. but the intent of some of the file api
is to allow the user access to the underlying FILE*, which you won't get if
the result is wrapped in object as a python file.

Anyway this is answered in 3 above.

Dave Hawkes










More information about the Cplusplus-sig mailing list