Lisandro Dalcin wrote:
> On Sat, Oct 10, 2009 at 12:15 PM, Stefan Behnel wrote:
>> I implemented the string CEP 108.
>>
>> One thing I changed was that you can assign a str literal to both char* and
>> bytes, i.e.
>>
>>        cdef char* s = "abc"
>>        cdef bytes b = "abc"
>>
>> will both work. I think that makes sense, given that char* and bytes are
>> mostly equivalent otherwise.
> 
> Mmm... Perhaps you could start by requiring an explicit 'b' prefix?
> 
> cdef bytes a = b"xyz" # OK
> cdef bytes b = "xyz"  # ERROR
> 
> We can relax this later (or just ignore this comment) if this
> restriction does not make sense...

It's not that it doesn't make sense, it's rather a case that (IMHO) has an
equilibrium of pros and cons. For example, you can do

        cdef char* c = "abc"
        cdef bytes b1 = c
        cdef bytes b2 = <char*>"abc"

but you can't do

        cdef bytes b = "abc"

It's easy to argue that the latter is a Python literal, sure, and that
makes me +0 for denying it. Also because

        s = "abc"

will actually give you a str object.


> How things will work in the case of "from __future__ import
> unicode_literals" ??

The CEP doesn't mention it, but that's just because there isn't any impact.
If you request unicode literals, you get them. That's handled in the parser.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to