[C++-sig] Return value policies for objects with custom to-python converters
Ravi
lists_ravi at lavabit.com
Fri Oct 3 23:00:03 CEST 2008
On Friday 03 October 2008 14:22:22 Roman Yakovenko wrote:
> > Python code:
> > import tuples
> > x = tuples.get2() # works
> > x = tuples.get1() # fails with conversion error
>
> I could be wrong, but it seems to be Boost.Python bug. I would submit
> bug report.
Ok, but this is a symptom of a more general problem: boost.python does not
allow one to plug in custom converters to work easily with its return value
policies. For example, I just figured out a hack to make return_by_value(!)
work for my custom converter (see my next mail replying to Neal Becker on the
mailing list).
> I thought about possible work around for you.
>
> Basically you can wrap functionality that registers custom converters
> and add that type to some global list. You can use
> boost::python::type_info class for the type description.
> Then you can create new call policy, that will query that list and
> will execute library "reference_existing_object" or yours.
That is a good idea, but I would like to see it fixed in boost.python; I tried
my hand at fixing it today but I was totally lost in the internals of
boost.python.
Regards,
Ravi
More information about the Cplusplus-sig
mailing list