Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 5, 2021

Conversation

gvanrossum
Copy link
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
Contributor

willingc commented Apr 4, 2021

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

@gvanrossum
Copy link
Member Author

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

@brandtbucher
Copy link
Member

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

@gvanrossum
Copy link
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