<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 16, 2015 at 12:05 PM, Philipp A. <span dir="ltr"><<a href="mailto:flying-sheep@web.de" target="_blank">flying-sheep@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">hi, nice work!<br><br>I like most of the ideas, except the semantic comments and some specific abstract classes.<br><br>so criticism first:<br><br>1. i don’t think comments should ever have an impact on the code.<br></blockquote><div><br></div><div>They don't. They also change the errors emitted by the static checker (which is not invoked when you run the code -- it is like a linter).<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">i’d prefer “assert isinstance(...)” for type annotations on variables.<br></blockquote><div><br></div><div>But that *would* affect runtime, by slowing down execution. Also for generic types the type checking could be either very slow (if checking List[int] would check every item of a list) or always fail (if a type variable is involved).<br><br></div><div>See discussion at <a href="https://github.com/ambv/typehinting/issues/35">https://github.com/ambv/typehinting/issues/35</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>2. also i don’t see why Dict, (non-abstract) Set, and List exist as long as we have Mapping and so on. Tuple is different because of its “Multiple return value” status and status as “is treated as Union[Class1, Class2] when used with instanceof(), except and friends”.<br><br>but checking for instanceof(..., list) is unpytonic! imho List and Dict really go against python’s data model and protocol-based nature.<br><br>i’d be for consistency: Set and MutableSet, Sequence and MutableSequence, Mapping and MutableMapping. no “abstract” (because all of this is abstract), no “frozen” (because frozen sets are just immutable sets and immutable behavior is a subset of the corresponding mutable behavior).<br></blockquote><div><br></div><div>But there is a lot of code that really needs the concrete types. E.g. list+list returns a list, but sequence+sequence may fail (as list+tuple exemplifies). Or list.sort. Etc.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Questions:<br><br>1. will we be able to use Union[...] in places like an except clause, where tuples are used to mean the same right now? would make sense imho<br></blockquote><div><br></div><div>No. Remember TOOWTDI. (Also the PEP intentionally stays far away from exception handling.)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2. what are ItemsView and KeysView for? what makes them different from FrozenSet or Sequence?<br></blockquote><div><br></div><div>They exist in collections.abc. Note that KeysView and ItemsView are (abstract) Sets, but ValuesView is not (you can have multiple equal values).<br clear="all"></div></div><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>
</div></div>