<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 23, 2017, at 12:10 PM, Brett Cannon <<a href="mailto:brett@python.org" class="">brett@python.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, 23 Jan 2017 at 04:27 INADA Naoki <<a href="mailto:songofacandy@gmail.com" class="">songofacandy@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jan 23, 2017 at 8:33 PM, Victor Stinner<br class="gmail_msg">
<<a href="mailto:victor.stinner@gmail.com" class="gmail_msg" target="_blank">victor.stinner@gmail.com</a>> wrote:<br class="gmail_msg">
> 2017-01-23 12:25 GMT+01:00 INADA Naoki <<a href="mailto:songofacandy@gmail.com" class="gmail_msg" target="_blank">songofacandy@gmail.com</a>>:<br class="gmail_msg">
>> I gave advice to use 'List[User]' instead of List[User] to the team of<br class="gmail_msg">
>> the project,<br class="gmail_msg">
>> if the team think RAM usage or boot speed is important.<br class="gmail_msg">
><br class="gmail_msg">
> I would prefer a Python option (ex: "-o noannotation" command line<br class="gmail_msg">
> option) to opt-out annotations rather than having to write annotations<br class="gmail_msg">
> in strings, which is IMHO more "ugly".<br class="gmail_msg"></blockquote><div class=""><br class=""></div><div class="">So basically the equivalent of -OO for docstrings? Maybe this can be the final motivator for some of us to come up with a design to generalize -O or something as it keeps coming up.</div></div></div></div></blockquote><div><br class=""></div><div>Yes, please. We've talked about generalizing this for years now. FWIW, I know of projects that run with -OO for the memory wins stemming from docstrings and had to codemod assert statements into a "prod_assert" function call to achieve this. If you think docstrings aren't that much, multiply this by a few hundred processes on a box and it ends up being a substantial win to strip them out.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
><br class="gmail_msg">
> Victor<br class="gmail_msg">
<br class="gmail_msg">
Personally speaking, I hope annotations are just static hint, and<br class="gmail_msg">
makes zero overhead at runtime.<br class="gmail_msg">
(startup time, memory consumption, and execution speed).<br class="gmail_msg"></blockquote><div class=""><br class=""></div><div class="">Local variable annotations are nothing but info in the AST. Parameter annotations and class annotations are stored on their respective objects so there's memory usage from that and the construction of them at object creation time, but that's it (e.g. the cost of creating func.__annotations__ when the function object is created is all you pay for performance-wise). And using strings will make those introspective attributes difficult to use, hence why I don't think people have said to do that everywhere.</div></div></div></blockquote><div><br class=""></div><div>I suggested making all annotations just strings at runtime and PEP 484 still lists this as a possible course for the future. So far Guido blocked this on a legitimate question: how much do type hints actually cost? Nobody knows yet, the biggest annotated codebase is at Dropbox and this is using comments (so no runtime cost).</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Anyway, many users are starting to use typing, for code completion or<br class="gmail_msg">
static checking.<br class="gmail_msg">
And very few user noticed it affects to performance of `isinstance(x,<br class="gmail_msg">
collections.Sequence)`.<br class="gmail_msg">
Python 3.7 may be too slow to help them.<br class="gmail_msg">
Can't we skip abc registration of typing.List[MyClass] completely?<br class="gmail_msg">
<br class="gmail_msg">
I'm sorry if it's silly idea. I don't know about background of<br class="gmail_msg">
current typing.py design. And I<br class="gmail_msg">
don't use abc much too.</blockquote><div class=""><br class=""></div><div class="">Since isinstance() checks are expected to be rare I don't think anyone has worried too much about the performance beyond the initial work to introduce ABCs and __instancecheck__.</div></div></div></blockquote><div><br class=""></div><div>Similar to the above, I would advise against crippling functionality unless we prove this is affecting performance in a significant way.</div><div><br class=""></div><div>- Ł</div></div></body></html>