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

2012-11-05 Thread mark florisson
On 4 November 2012 22:32, Olivier Parcollet  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@python.org
> http://mail.python.org/mailman/listinfo/cython-devel
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


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

2012-11-05 Thread Stefan Behnel
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.

Stefan

___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


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

2012-11-05 Thread Robert Bradshaw
On Mon, Nov 5, 2012 at 7:00 AM, Stefan Behnel  wrote:
> 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.

Yep. It's a question of complicating the language and coming up with
the right syntax. For the stl containers, we decided to implement them
directly and cross the generic bridge at some later point. Certainly
worth writing up a proposal as a CEP
http://wiki.cython.org/enhancements .

- Robert
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel