Thanks for the comments, Guido! I'll be slowly working through them over the next few days. For the `Tuple` discussion: overall, it sounds like this would be complicated enough to sort out that it would be best left for a future PEP. I don't think there's anything in the PEP as it stands that would prevent us tacking on either of these two mechanisms later - as long as we make the constructor for variadic type variables different to `TypeVar`, so there's no problem potentially adding extra arguments to the constructor later on. On Mon, 14 Dec 2020 at 19:38, Pradeep Kumar Srinivasan via Typing-sig < typing-sig@python.org> wrote:
It occurs to me that there's one other attribute that makes `tuple` special. It accepts zero-length lists (i.e. `tuple[()]`). Would the proposed variadic TypeVar mechanism also support this? For example, would `Tensor[()]` be legal?
Yes, zero-length Tuples are valid as arguments for Ts. That is the case, for example, when we have def foo(*args: *Ts) -> Ts: ... and we call it with no arguments: foo(). Ts would then resolve to Tuple[()]. Likewise, Tensor[()] is also legal.
-- Pradeep
------------------------------ *From:* Eric Traut <eric@traut.com> *Sent:* Monday, December 14, 2020 9:38 AM *To:* typing-sig@python.org <typing-sig@python.org> *Subject:* [Typing-sig] Re: Variadic generics PEP draft
Perhaps my choice of the term "arbitrary length" was confusing here. Alternatives might be "unknown length" or "unspecified length".
It occurs to me that there's one other attribute that makes `tuple` special. It accepts zero-length lists (i.e. `tuple[()]`). Would the proposed variadic TypeVar mechanism also support this? For example, would `Tensor[()]` be legal?
Perhaps `tuple` is just too much of an oddity for us to model using the proposed variadic TypeVar mechanism. I figured it was at least worth exploring the idea, so thanks for the discussion.
-Eric _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: gohanpra@gmail.com _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: mrahtz@google.com