On Wed, Jan 29, 2020 at 1:51 PM Saul Shanabrook via Typing-sig <typing-sig@python.org> wrote:
> Yeah, my main question is whether we should do this or not -- if we decide
we need to do this it won't be that hard to do, but it would mean the C
code is more complicated, and we couldn't change it as easily if we found
problems.

If we do, it would be nice if this was accessible as an externally available function, like `replace_typevars(list[int, T], {T: str})`. I imagine this would require another PEP though?

It's trivial to code this yourself though using the __origin__ and __parameters__/__args__ attributes. I don't think it's worth having in the stdlib. I don't actually want to encourage introspecting generics -- I begrudgingly allow it.
 
AFAIK there haven't been any designs on including a library in core that allows you to manipulate and compare types as first class entities, is that right? Along with replacing typevars, it would nice to have a builtin way of being able to walk a type tree, extract typevars (i.e. `extract_typevars(list, list[str]) == {T: str})`), and check for subtype compatibility.

See above for why not. :-)

--
--Guido van Rossum (python.org/~guido)