[Python-ideas] Variable-length, homogeneous tuple: why? (was: Optional static typing -- the crossroads)

Łukasz Langa lukasz at langa.pl
Mon Aug 18 01:47:49 CEST 2014


On Aug 17, 2014, at 4:40 PM, Chris Angelico <rosuav at gmail.com> wrote:

> Et voila. Now just define that frozenlist[int] is like list[int]
> rather than like tuple[int], and there you are, out of your difficulty
> at once!

That's a neat trick and I think Guido suggested this naming before. It feels a little icky though, consider:

- issubclass(tuple[int, int, int], frozenlist[int]) ?  I think True.
- issubclass(frozenlist[int], tuple[int, int, int]) ?  I would think False. But because that's technically the same tuple underneath, *sometimes* instances of frozenlist[int] will respond True to isinstance(tuple[int, int, int]).

Saying explicitly tuple[int, ...] takes that riddle away.


-- 
Best regards,
Łukasz Langa

WWW: http://lukasz.langa.pl/
Twitter: @llanga
IRC: ambv on #python-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140817/0ba9cd52/attachment.html>


More information about the Python-ideas mailing list