Stefan Behnel | 18 Aug 22:07

[Cython] print statement under Py3k

Hi,

Dag Sverre Seljebotn wrote:
> There's a problem if you do an empty print (newline
> print) right after a non-newline print. The attached test case works in
> Py2 but fails in Py3 (the line with "2 2 2" is output as "2 2 2 " instead).

> for i in range(3):
>        print 2,
> print

Right, that makes sense. The Py3 print() function (that we map the print
statement to when running under Py3) has an explicit 'end' keyword that keeps
it from having to do any "softspace" special casing. So this is a difference
that is hard to emulate in Py3, which (as opposed to Py2) does not expose the
softspace hint at all.

http://www.python.org/dev/peps/pep-3105/

Open poll:

a) would it be acceptable if this difference persisted, i.e. if Cython code
   that uses something like the example above would behave different in Py3
b) should Cython try to special case this in Py3 to emulate the Py2 behaviour
   in common cases
c) should Cython stick to the Py3 behaviour also in Py2 (thus breaking the
   complete semantics of the print statement)

?

(Continue reading)

Dag Sverre Seljebotn | 18 Aug 22:24

Re: [Cython] print statement under Py3k

Stefan Behnel wrote:
> Hi,
> 
> Dag Sverre Seljebotn wrote:
>> There's a problem if you do an empty print (newline
>> print) right after a non-newline print. The attached test case works in
>> Py2 but fails in Py3 (the line with "2 2 2" is output as "2 2 2 " instead).
> 
>> for i in range(3):
>>        print 2,
>> print
> 
> Right, that makes sense. The Py3 print() function (that we map the print
> statement to when running under Py3) has an explicit 'end' keyword that keeps
> it from having to do any "softspace" special casing. So this is a difference
> that is hard to emulate in Py3, which (as opposed to Py2) does not expose the
> softspace hint at all.
> 
> http://www.python.org/dev/peps/pep-3105/
> 
> Open poll:
> 
> a) would it be acceptable if this difference persisted, i.e. if Cython code
>    that uses something like the example above would behave different in Py3
> b) should Cython try to special case this in Py3 to emulate the Py2 behaviour
>    in common cases

+1; though it ends up on the list of priorities we all keep in the back 
of our head and then it is sure to end up pretty low :-) But I think 
this is the optimal option.
(Continue reading)

Robert Bradshaw | 19 Aug 00:43

Re: [Cython] print statement under Py3k

On Mon, 18 Aug 2008, Stefan Behnel wrote:

> Hi,
>
> Dag Sverre Seljebotn wrote:
>> There's a problem if you do an empty print (newline
>> print) right after a non-newline print. The attached test case works in
>> Py2 but fails in Py3 (the line with "2 2 2" is output as "2 2 2 " instead).
>
>> for i in range(3):
>>        print 2,
>> print
>
> Right, that makes sense. The Py3 print() function (that we map the print
> statement to when running under Py3) has an explicit 'end' keyword that keeps
> it from having to do any "softspace" special casing. So this is a difference
> that is hard to emulate in Py3, which (as opposed to Py2) does not expose the
> softspace hint at all.
>
> http://www.python.org/dev/peps/pep-3105/
>
> Open poll:
>
> a) would it be acceptable if this difference persisted, i.e. if Cython code
>   that uses something like the example above would behave different in Py3
> b) should Cython try to special case this in Py3 to emulate the Py2 behaviour
>   in common cases
> c) should Cython stick to the Py3 behaviour also in Py2 (thus breaking the
>   complete semantics of the print statement)
>
(Continue reading)

Stefan Behnel | 19 Aug 11:25

Re: [Cython] print statement under Py3k

Robert Bradshaw wrote:
> On Mon, 18 Aug 2008, Stefan Behnel wrote:
>> Dag Sverre Seljebotn wrote:
>>
>>> for i in range(3):
>>>        print 2,
>>> print
>>
>> Right, that makes sense. The Py3 print() function (that we map the print
>> statement to when running under Py3) has an explicit 'end' keyword that
>> keeps
>> it from having to do any "softspace" special casing. So this is a
>> difference
>> that is hard to emulate in Py3, which (as opposed to Py2) does not
>> expose the softspace hint at all.
>>
>> http://www.python.org/dev/peps/pep-3105/
>>
>> Open poll:
>>
>> a) would it be acceptable if this difference persisted, i.e. if Cython
>> code
>>   that uses something like the example above would behave different in
>> Py3
>> b) should Cython try to special case this in Py3 to emulate the Py2
>> behaviour
>>   in common cases
>> c) should Cython stick to the Py3 behaviour also in Py2 (thus breaking
>> the
>>   complete semantics of the print statement)
(Continue reading)


Gmane