[C++-sig] Re: Boost.Python: few thoughts and questions... [PATCH]

Nicodemus nicodemus at globalite.com.br
Sat Jun 14 00:42:29 CEST 2003


Roman Sulzhyk wrote:

>Guys:
>
>Anyway, here's a patch with some rather raw hacks so far, if this
>functionality is useful to Nicodemus I can definitely clean this up.
>The patch is against stock 1.3.0 pyste.
>  
>

Looks great, thanks a lot Roman! I will apply the patch as soon as I can.

>1) Is it worthwhile to add a 'default reference policy' to pyste, i.e.
>a default conversion (like copy_const_reference) which will be used in
>case one isn't specified explicitely. This will be useful for
>situations where one has an API which returns a bunch of const
>std::string &, to avoid having to specify them function by function.
>

No, there isn't. But Pyste automatically uses copy_const_reference if a 
member function returns something by constant reference... try using the 
latest CVS.

>2) How about adding 'converter' functionality to pyste, i.e. ability to
>register default converters using to_python_converter<> ?
>

That is indeed something that is missing. For pyste it is simple, we 
just need to provide a function to the user that inserts the specific 
code into the BOOST_PYTHON_MODULE:

Include("my_converters.h")
to_python_converter("converters::vector_to_list", "PyListType")

Would generate:

#include <my_converters.h>

BOOST_PYTHON_MODULE(...)
{
    to_python_converter<converters::vector_to_list, PyListType>(); // 
from the top of my head
    ...
}

Something like this would do?

Regards,
Nicodemus.





More information about the Cplusplus-sig mailing list