[Cython] Custom automatic type conversions from/to C++

mark florisson markflorisson88 at gmail.com
Mon Nov 5 12:02:43 CET 2012


On 4 November 2012 22:32, Olivier Parcollet <oparcollet.triqs at gmail.com> wrote:
> Hello,
>
> 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. This is
probably best addressed and proposed in the form of a CEP. You could
then add a plugin that allows users to add C++ conversion rules. Some
parts of the Cython code base may have to be adapted to allow them to
be pluggable without monkey-patching Cython.

A start could be just inserting new visitors and overriding C++
conversions, and leave the rest to the next person that wants to do
more.

> Best,
>
> Olivier
>
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel


More information about the cython-devel mailing list