On Fri, Dec 11, 2009 at 11:02 PM, Greg Ewing
<[email protected]> wrote:
> I've had an idea that might help with making the
> encoding and decoding of unicode strings more
> automatic.
>
> Suppose we have a way of expressing a type parameterised
> with an encoding, maybe something like
>
>   encoding[name]
>
> We could have a few predefined ones, such as
>
>   ctypedef encoding['ascii'] ascii
>   ctypedef encoding['utf8'] utf8
>   ctypedef encoding['latin1'] latin1
>

Just in case, did you mean

ctypedef encoding['ascii'] char* ascii
ctypedef encoding['utf8'] char* utf8
ctypedef encoding['latin1'] char* latin1

??

>
> What do you think?
>

Long time ago (about 4 years), Guido commented on Python-Dev that
Greg's taste in
language features is hard to beat.


> Seems like this sort of scheme would
> keep the encoding being used at each point fairly explicit
> without being too intrusive.
>

I think this does not handle Robert's concern of updating all the code
in Sage, as still every usage of char* will need review. But Greg's
proposal would be really handy for NEW code targeting Py3k. Moreover,
Robert's idea of using compiler directives to automate the char* <->
str conversion could build on Greg's proposal.

In short, I'm definitely +1 on this approach.

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to