[Cython] Cannot coerce list to type 'list'

Robert Bradshaw robertwb at math.washington.edu
Thu Dec 18 18:55:38 CET 2008


On Dec 18, 2008, at 3:53 AM, Muhammad Alkarouri wrote:

> 2008/12/18 Robert Bradshaw <robertwb at math.washington.edu>:
>> On Dec 17, 2008, at 4:25 PM, Muhammad Alkarouri wrote:
>>
>>> On Dec 17, 2008, Robert Bradshaw wrote:
>>>
>>>> What is the definition of list in c_python? If it's a cdef extern
>>>> class of the actual python list, then this is a bug and should  
>>>> work.
>>>> Also, you might not need c_python anymore.
>>>
>>> Thanks, that does the trick.
>>> The __builtin__.list was cdef extern in the c_python.pxd (shown
>>> below), I simply commented it and the code worked fine.
>>> Is there a fault with how I have it written, or should I report it
>>> as a bug now?
>>
>> I'm not sure what the best thing to do here is (certainly it could be
>> fixed to ignore these extern types that match), but there's no
>> advantage to declaring the empty dict and list types as Cython
>> understands those types natively now.
>>
>
> I suggested to report it according to your earlier suggestion, but I
> would say the best way forward for Cython is to explicitly deprecate
> the practice of declaring types that are defined by Cython. Say,
> cython should fail with a kind of duplicate error or 'new definition
> overrides cython built in' kind of message. The idea is that:
>
> 1. The will be less hairy code and more maintainable for cython  
> developers.
> 2. For a cython user like me, such a failure would be clear enough to
> modify the source in accordance.
> 3. Cython will probably grow more capabilities in types and other
> optimizations in the future. These may replace user defined ones. If
> users are used to this kind of change this will give Cython developers
> more leeway in doing improvements in types and functions.
>
> In short, I would fix that by giving a clearer error and also clearly
> noting that in the documentation. The user should expect to have to
> delete the offending duplicate type or function. Does that make sense?

Yes, that sounds very reasonable.

http://trac.cython.org/cython_trac/ticket/170

- Robert




More information about the Cython-dev mailing list