Doc: match statement in style guide (#5187)

* Test: add micro benchmark for match

* Doc: add 'match' to python style guide
This commit is contained in:
black-sliver
2025-07-14 07:22:10 +00:00
committed by GitHub
parent a9b35de7ee
commit ec3f168a09
2 changed files with 70 additions and 0 deletions

View File

@@ -29,6 +29,10 @@
* New classes, attributes, and methods in core code should have docstrings that follow
[reST style](https://peps.python.org/pep-0287/).
* Worlds that do not follow PEP8 should still have a consistent style across its files to make reading easier.
* [Match statements](https://docs.python.org/3/tutorial/controlflow.html#tut-match)
may be used instead of `if`-`elif` if they result in nicer code, or they actually use pattern matching.
Beware of the performance: they are not `goto`s, but `if`-`elif` under the hood, and you may have less control. When
in doubt, just don't use it.
## Markdown