[Cython] Custom automatic type conversions from/to C++
stefan_ml at behnel.de
Mon Nov 5 16:00:58 CET 2012
mark florisson, 05.11.2012 12:02:
> On 4 November 2012 22:32, Olivier Parcollet wrote:
>> I would like to write some automatic C++/python conversionsfor the
>> classes of my project
>> in addition to std::vector and others std:: objects.
>> Conversions for std:: objects are written in
>> Cython/Utility/CppConvert.pyx, i.e. an internal cython file.
>> The question is then simply to load another CppConvert.pyx file that
>> would be project dependent.
>> Is there already a way to do it ?
>> or a plan to do provide such user defined conversions ?
>> I made a simple patch to load also another CppConvert.pyx from the
>> current directory,
>> which works for my code, but I would welcome a more general solution...
> Great. Ideally, Cython would be plugable, allowing one to use a
> documented API and to insert new visitors at certain points in the
> pipeline, allowing custom transformations and utilities
I wouldn't call that "ideal". In case we want to support this kind of
extensions, it should happen at the source code level, not hook into the
compiler pipeline as part of the build process.
IMHO, the right way to provide custom type conversions is by declaring
them, e.g. as part of a C++ class declaration.
BTW, I'm sure this has been discussed more than once on this list.
More information about the cython-devel