[C++-sig] pyplusplus: Feature requests

Matthias Baas baas at ira.uka.de
Sun Feb 26 13:57:46 CET 2006


now that I have a working module that I can play around with, I came 
upon some stuff that I'd like to see in pyplusplus:

- When keywords are disabled on a constructor any optional argument is 
turned into a non-optional argument. Pyste uses the optional<> construct 
to set optional values. It would be great if pyplusplus would do that as 
well, so that optional values are still optional even when keywords are 
not specified. So for example, if there's a constructor that takes 3 
doubles from which two are optional, Pyste generates:

   .def(init< double, optional< double, double > >())

I haven't checked, but maybe this scheme even works with keyword 
arguments...? (which would solve the registration order problem for 

- Copy constructors don't get wrapped

- Index operators don't get wrapped

- Friend functions that implement operators for a class don't get 
wrapped (for example, if you have a 3D vector class and you implement 
the scalar multiplication with a float you need such a friend function 
if you also want to support the expression float*vec and not only 

By the way, here I don't understand why I actually can multiply my 
vectors with an integer (even from both sides), but not with a float 
from the right side. The following are all the defs in my vector that 
deal with multiplication:

   MVector_exposer.def( bp::self * bp::self );
   MVector_exposer.def( bp::self * bp::other< double >() );
   MVector_exposer.def( bp::self * bp::other< MMatrix >() );

So why can I multiply my vector with an integer? (the C++ class does 
allow that but the stuff isn't wrapped) And if I try to multiply a float 
from the left side I get:

TypeError: can't multiply sequence by non-int


- When using a cache the order of enum values changes in the generated 
source files from call to call. This leads to new compilations that 
wouldn't be necessary.

- Are there any plans on adding some support for creating wrapper 
methods in cases where they are absolutely necessary? Suppose you have a 
method void getSize(int& width, int& height) that returns the resolution 
of an image. pyplusplus currently wraps that method happily without 
issuing a warning, but I'm not even able to call that function from 
Python, let alone will it ever do what it's supposed to do. I don't 
expect pyplusplus to deal with such cases in a fully automated manner 
(as to date, reading the user's mind is still out of scope of such tools 
;) but it could help the user resolve these things. A minimal aid would 
simply be to report such methods that might not work in Python so that 
the user knows he has to do something about it. Maybe for some cases we 
could provide some automatic wrapper generation once the user has 
specified which arguments are actually output values and shouldn't be 
part of the argument list in Python.

- Matthias -

More information about the Cplusplus-sig mailing list