Stefan Behnel schrieb:
> Lisandro Dalcin, 24.11.2009 22:18:
>> On Tue, Nov 24, 2009 at 5:32 PM, Stefan Behnel <[email protected]> wrote:
>>> Joachim Saul, 24.11.2009 20:59:
>>>> cdef extern from "Python.h":
>>>> ctypedef class __builtin__.str [object PyStringObject]:
>>>> pass
>>> Remove the above and use the 'bytes' type in the rest of your code instead.
>>> 'str', 'unicode' and 'bytes' are builtin types in Cython.
>> Anyway, any good reason for such code to fail in Cython? Should we
>> support such declarations of builtin types? I think Cython should be
>> able to compile as much Pyrex code as possible.
>
> Well, supporting this would mean that we'd have to check the above
> declaration, including the header file name and all potentially declared
> type fields.
>
> Forbidding it is a lot easier, I think.
1st of all thanks for the helpful replies.
Indeed, Pyrex compatibility is a requirement for me. I want to use/test
the Cython-generated code but need to be able to revert to Pyrex in case
of problems. Anyway, what I have done is
def foo(bytes bar=bytes("")):
c_foo(bar)
This compiles and works under both Cython and Pyrex, so for the sake of
compatibility, this seems to be the way to go for the time being.
But doesn't the explicit conversion seem pretty redundant/ugly?
Cheers,
Joachim
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev