[Python-ideas] A suggestion for Python 3 vs Python 2

Xuancong Wang xuancong84 at gmail.com
Tue Nov 12 06:52:51 CET 2013


>You probably ought to weigh the ease of typing against readability. Which
is more important? By how much?
As people are used to python2, I don't think changing print to print() will
improve code readability by how much, especially now VIM already highlights
the print command in python. Probably you don't use print in python quite
often, so you may not sense the difference in typing brackets. If you ever
used C/C++/perl frequently, you should sense the inconvenience caused by
brackets in loop structures.

>Separately, have you measured typing speed rigorously?
The typing effort varies from person to person, from beginners to experts,
maybe you are too expert to sense the difference which is sensitive to
beginners. There's no rule-of-thumb and it's not just a speed issue. It's
also related to energy spent by your fingers.  So obviously, pressing 2
keys, you need to spend at least twice the amount of energy. And even more
if you need to hold down 1 key.

Anyway, I am just introducing an alternative form to the print() function.
As long as this does not reduce the performance of the interpreter
significantly, it should not harm. And it should also improve the downward
compatibility.


On Tue, Nov 12, 2013 at 1:27 PM, Guido van Rossum <guido at python.org> wrote:

> You probably ought to weigh the ease of typing against readability. Which
> is more important? By how much? If 10% more effort typing makes for 5%
> better readability, but the code is read 5 times as often as it is edited,
> is that then worth it?
>
> Separately, have you measured typing speed rigorously?
>
> On Monday, November 11, 2013, Xuancong Wang wrote:
>
>> >An interesting methodology; however, I think PERL already has
>> >conquered this corner of the language world.
>>
>> I think Perl has much lower efficiency than python, especially you need
>> to type a $ before every variable. The input effort of $ is very high
>> because you need to press shift.
>>
>> Also, you need to type {} for every function/for/while structure.
>>
>> In terms of language efficiency, I think Perl is no comparison to Python.
>>
>> We can roughly estimate the input effort of every key in the following
>> way:
>> Normal alphabet keys: effort=1
>> Numbers 0~9: effort=1.2
>> Shift/Tab: effort=0.6
>> Ctrl/Alt: effort=0.8
>> {}[];'\,./-=: effort=1.2
>> (effort measures how difficult it is to press the key)
>> Therefore, any composed keys like shift+9='(',  the input effort is
>> 0.6+1.2=1.8
>> that's why we should try to avoid composed keys if it's not necessary.
>>
>> >>"Advantages of print being a function:
>> * You can override it. Can't do that with a special language element.
>> * It can be used in map, lambda, and other expression contexts.
>> * Precedence etc follows the normal rules of functions - the arguments
>> are all tidily enclosed.
>> * Keyword arguments, rather than magical syntax, handle the oddities
>> like end=" ".
>> * You can easily alias it: "p = print; p('Hello, world!')"
>>
>> I do agree that print should remain as a function logically. But is there
>> a way to make it as simple as in python 2, or even simpler, for example:
>> pr >>sys.stderr, 'hello world'
>>
>> xuancong
>>
>>
>> On Tue, Nov 12, 2013 at 11:56 AM, Mark Janssen <dreamingforward at gmail.com
>> > wrote:
>>
>>> On Mon, Nov 11, 2013 at 7:45 PM, Xuancong Wang <xuancong84 at gmail.com>
>>> wrote:
>>> > As you know, reading from and writing to IO is a high frequency
>>> operation.
>>> > By entropy coding theorem (e.g. Huffman coding), an efficient language
>>> > should assign shorter language code to more frequent tasks. Typing a
>>> '('
>>> > requires holding SHIFT and pressing 9, the input effort is much higher
>>> than
>>> > that in Python 2. Also, specifying IO has changed from >>* to file=*,
>>> which
>>> > also becomes more inconvenient.
>>>
>>> An interesting methodology; however, I think PERL already has
>>> conquered this corner of the language world.
>>> --
>>> MarkJ
>>> Tacoma, Washington
>>>
>>
>>
>
> --
> --Guido van Rossum (on iPad)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131112/da686bac/attachment.html>


More information about the Python-ideas mailing list