[Python-ideas] Proposal to extend PEP 484 (gradual typing) to support Python 2.7

Andrew Barnert abarnert at yahoo.com
Mon Jan 11 18:04:46 EST 2016


On Jan 11, 2016, at 13:38, Guido van Rossum <guido at python.org> wrote:
> 
>> On Mon, Jan 11, 2016 at 12:22 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
>>> On Jan 11, 2016, at 10:42, Gregory P. Smith <greg at krypto.org> wrote:
>>> 
>>> The goal of the # type: comments as described is to have this information for offline analysis of code, not to make it available at run time.  Yes, a decorator syntax could be adopted if anyone needs that. I don't expect anyone does. Decorators and attributes would add run time cpu and memory overhead whether the information was going to be used at runtime or not (likely not; nobody is likely to deploy code that looks at __annotations__).
>> 
>> These same arguments were made against PEP 484 in the first place, and (I think rightly) dismissed.
> 
> The way I recall it the argument was made against using decorators for PEP 484 and we rightly decided not to use decorators.

Sure. But you also decided that the type information has to be there at runtime.

Anyway, I don't buy GPS's argument, but I think I buy yours. Even if there are good reasons to have annotations at runtime, and they'd apply to debugging/introspecting/etc. code during a 2.7->3.6 port just as much as in new 3.6 work, but I can see that they may not be worth _enough_ to justify the cost of extra runtime CPU (which can't be avoided in 2.7 the way it is in 3.6). And that, even if they were worth the cost, it may still not be worth trying to convince a team of that fact, especially without any hard information). 

>> 3.x code with annotations incurs a memory overhead, even though most runtime code is never going to use them. That was considered to be acceptable. So why isn't it acceptable for the same code before it's ported to 3.x? Or, conversely, if it isn't acceptable in 2.x, why isn't it a serious blocking regression that, once the port is completed and you're running under 3.x, you're now wasting memory for those useless annotations?
> 
> I'm not objecting to the memory overhead of using decorators,

OK, but GPS was. And he was also arguing that having annotations at runtime is useless. Which is an argument that was made against PEP 484, and considered and rejected at the time. Your argument is different, and seems convincing to me, but I can't retroactively change my reply to his email.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160111/20aa0ee8/attachment.html>


More information about the Python-ideas mailing list