Thanks very much for the survey (which actually surprised me somewhat).

Regarding the suggested update for the PEP, I'll make a PR to change that
-- I agree it's worth saying it.

On Sat, Nov 21, 2020 at 5:00 PM David Foster <davidf...@gmail.com> wrote:

> On 11/19/20 10:08 PM, David Foster wrote:
> > I've completed my survey of how other languages use pattern matching to
> > match Mapping-like and dict-like types, especially focusing on whether
> > they ignore (𝔸) or disallow (𝔹) extra keys by default. [...]
>
> To close the loop on this thread:
>
> * Based on (1) the explanation from PEP 622 and Guido RE that  "mappings
> [...] have natural structural sub-typing behavior, i.e., passing a
> dictionary with extra keys somewhere will likely just work" and (2) the
> survey results, I'm now personally fine (+0) with keys being ignored by
> default when matching against mappings.
>
>
> * I do think it might be illustrative to copy the following explanatory
> sentences from the "Mapping Patterns" section of the older PEP 622 to
> the same section of PEP 635 (Structural Pattern Matching: Motivation and
> Rationale):
>
>  > Extra keys in the subject are ignored even if **rest is not present.
> This is different from sequence pattern, where extra items will cause a
> match to fail. But mappings are actually different from sequences: they
> have natural structural sub-typing behavior, i.e., passing a dictionary
> with extra keys somewhere will likely just work.
>
> Specifically the above might replace the following sentence in PEP 635,
> which doesn't really give a rationale:
>
>  > Moreover, the mapping pattern does not check for the presence of
> additional keys.
>
>
> * I still have an interest in strictly matching dictionaries that are
> destined to become TypedDicts, but I can take that conversation to a
> different thread.
>
> --
> David Foster | Seattle, WA, USA
> Contributor to TypedDict support for mypy
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/K5BUKMOCIBUQIITBUQNX6KEHOB4WB5BC/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4VCATZRVSNIZM4YUJJHCIDE6ARKO6LE6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to