Stop writing Python 4 incompatible code

Terry Reedy tjreedy at udel.edu
Thu Jan 14 00:45:57 EST 2016


On 1/13/2016 8:02 PM, Rick Johnson wrote:
> and a leader who lost his cushy job at Google

Unless you have access to facts that I do not, 'lost' is impolite 
speculation. But lets move on.

I have a contrary hypothesis based on the facts quoted below.  As far as 
I know, Google is somewhat stuck on 2.7.  Dropbox, on the other, is 
migrating to modern 3.x Python (see below).  Guido wants the world to do 
this, so he moved to a company where he can help make this practical, by 
helping to work out some of the practical details of how to do so, and 
then share them with the rest of the Python community.

On Jan 8, 6 days ago, Guido posted on python-idea "Proposal to extend 
PEP 484 (gradual typing) to support Python 2.7"

"At Dropbox we're trying to be good citizens and we're working towards 
introducing gradual typing (PEP 484) into our Python code bases (several 
million lines of code). However, that code base is mostly still Python 
2.7 and we believe that we should introduce gradual typing first and 
start working on conversion to Python 3 second (since having static 
types in the code can help a big refactoring like that).

Since Python 2 doesn't support function annotations we've had to look 
for alternatives. We considered stub files, a magic codec, docstrings, 
and additional `# type:` comments. In the end we decided that `# type:` 
comments are the most robust approach. We've experimented a fair amount 
with this and we have a proposal for a standard."

A few days later, in the absence of objection to the proposed comment 
syntax, he added the proposal.  Not mentioned in the quote is that mypy 
will support the new comments for static analysis.  2.x interpreters 
will happily ignore then.

If Dropbox comment-annotates a public 2.x package, it can contribute the 
work back for the use of others.  Google, on the other hand, decided to 
support annotation in 2.7 creating a custom 2.7 interpreter than will 
ignore them.  Any code annotated by Google will be useless on standard 
interpreters without being run through a converter.

-- 
Terry Jan Reedy




More information about the Python-list mailing list