Description
CPython 3.10 release candidate 2 is now out, and the final release is less than two weeks away. By far the biggest change in the release is support for the new Structural Pattern Matching syntax. This is by far the most substantial language change Python has seen since the arrival of the walrus operator :=
, and probably since the release of Python 3.
(Those not familiar with Structural Pattern Matching should probably start by reading PEP 635 which covers the motivation for this new language feature. There are separate PEPs for the full specification and a tutorial.)
Structural Pattern Matching is a big and fairly complex feature; adding it to Micropython would be a fair amount of work and add quite a bit of code to the parser. How much work and how much code are open questions, as is the question of when, if ever, it will be worth doing? The answer to this last question will depend very much on how rapidly users of CPython embrace, and come to depend on, this new feature. That said, the new syntax can save a lot of source code typing; if it gets rapid and windspread uptake it would represent a substantial incompatibility between Micropython and CPython.
Given how significant an addition this is to the Python syntax, it seems like it would be a good idea to understand the work involved and the scope of the change well before use of it in CPython becomes widespread. I am opening this issue to serve as a place to discuss those topics.