[Pyrex] [Cython] Python 3

Stefan Behnel stefan_ml at behnel.de
Tue Apr 29 09:36:05 CEST 2008


Hi again,

sorry, I only had a quick glimpse on your mail before replying.

Stefan Behnel wrote:
> Greg Ewing wrote:
>> Something that doesn't seem to have been considered
>> as much as it needs to be is the issue of memory
>> management. Currently, coercing a Python string
>> into a char * doesn't require allocating an memory.
>>
>> But if a re-coding operation is required
> [...]
>
> No re-coding, no memory allocation. Please read the (lengthy) thread we
> had on the Cython list about this topic.
>
> http://comments.gmane.org/gmane.comp.python.cython.devel/1043

That's the thread that Robert pointed you to, so you did read it. I guess
you were referring to Dag's proposal of a type based conversion syntax?
It's not currently clear if that will ever be implemented, as it's
actually flawed. If you say you want a UTF-8 byte encoded string as a
char*, and Cython/Pyrex automatically converts it from a Unicode string
for you - how do you handle byte strings as parameters? Do you just accept
them as "maybe being UTF-8 encoded"? Wouldn't you want to have 'type
checking' in that case? Do you want Cython/Pyrex to reject them for you?
That's the real problem. I think I sort-of expressed that here:

http://codespeak.net/pipermail/cython-dev/2008-April/000520.html

For me, the more important conclusion of that thread is that there will be
no automatic conversion in the background, so all conversion operations
will be explicit. It's good to make users aware of the transition between
bytes and characters, I think that's the whole idea behind the changes in
Py3 anyway.

Stefan




More information about the Pyrex mailing list