[Pyrex] [Cython] Python 3

Robert Bradshaw robertwb at math.washington.edu
Tue Apr 29 17:35:12 CEST 2008


On Apr 29, 2008, at 2:55 AM, Christian Heimes wrote:
> Greg Ewing schrieb:
>> About half the posts seemed to be suggesting that there
>> should be some kind of automatic coercion from a Python
>> unicode string to a char *, but only one even mentioned
>> the issue of the memory allocation that this would
>> require.
>>
>> Has a scheme been settled on that would avoid any of
>> these problems? If so, is there somewhere I can go to
>> read a clear summary of what's been decided?
>
> FYI:
> In Python 3.x the PyUnicode object keeps a default encoded PyString in
> its struct. You can use PyUnicode_AsStringAndSize() to get an UTF8
> encoded char* from a PyUnicode object without worrying about memory
> management.

Yep. This was my point about unicode objects supporting the buffer  
interface, so we wouldn't need to worry about memory management (or  
even copying if the encoded string had already been computed).

The bigger point was that both Stefan and Dag thought "char* s = o"  
should be an error for an object o--no automatic conversion forcing  
the user to make everything explicit.

- Robert
  



More information about the Pyrex mailing list