Skip to content

PEP 634: Change so __match_args__ must be a tuple#1909

Merged
gvanrossum merged 2 commits intomasterfrom
match-args-tuple
Apr 5, 2021
Merged

PEP 634: Change so __match_args__ must be a tuple#1909
gvanrossum merged 2 commits intomasterfrom
match-args-tuple

Conversation

@gvanrossum
Copy link
Copy Markdown
Member

@gvanrossum gvanrossum commented Apr 3, 2021

This was discussed on python-dev in the thread
https://mail.python.org/archives/list/python-dev@python.org/thread/YYIT3QXMLPNLXQAQ5BCXE4LLJ57EE7JV/#YYIT3QXMLPNLXQAQ5BCXE4LLJ57EE7JV

I don't think anyone disagrees that it's better if __match_args__ is required to be a tuple.

  • This helps static type checkers keep track of the values more easily
  • It allows an optimization in the implementation where the pattern only needs to be recompiled when the value is changed.

@willingc
Copy link
Copy Markdown
Contributor

willingc commented Apr 4, 2021

@gvanrossum It looks like line 498 has an extra "`" around match_args

@gvanrossum
Copy link
Copy Markdown
Member Author

@brandtbucher -- How do you feel about implementing this change?

@brandtbucher
Copy link
Copy Markdown
Member

@gvanrossum No problem, I'll have something up later today.

@gvanrossum
Copy link
Copy Markdown
Member Author

I think this is now sufficiently non-controversial that I'm just changing the PEP and we'll update the implementation ASAP (not sure if it will make 3.10a7, if not then definitely b1).

@gvanrossum gvanrossum merged commit d635956 into master Apr 5, 2021
@gvanrossum gvanrossum deleted the match-args-tuple branch April 5, 2021 17:38
gvanrossum pushed a commit to python/cpython that referenced this pull request Apr 6, 2021
See:
- python/peps#1909 (__match_args__ must be a tuple)
- python/peps#1908 (allow keyword patterns for int(x) etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants