Moshmosh
The TRUE implementation of pattern matching for Python.
For more than pattern matching, check syntax_rule.py.
@syntax_rule(pattern_matching)
def f(x, r=1):
with match(x):
if case[0]: return 1
if case[x]: return f(x-1, r * x)
return f(10)
Features
-
Tree pattern matching:
if C1(C2(1), ""): ... -
Unlike projects using
inspect.getsource, syntax extensions are achieved without evil IO operations or requiring source files. -
Literal patterns:
- string, number and other constant patterns
- tuple, list patterns
-
Provided with the capabilities to customize semantics of python syntaxes.
Benchmarks
Check benchmark.py.
Although Pampy is much weaker than moshmosh, it's also much slower than moshmosh :) . Note tha moshmosh is currently a simple prototype implemented in few hours.
Thus we can safely conclude, A true one is always better than the fakers.
Acknowledgements
See older implementations and search "pattern matching" in Python-ideas.
Salute all the people used to work for Python pattern matching.
Metadata
Release files for moshmosh-syntax 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| moshmosh_syntax-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / moshmosh_syntax-0.1.1-py3-none-any.whl
| Download URL | moshmosh_syntax-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2684991b960ed3bae67b2cfaf0e3f35c9173ffba4c7fa31106af9d321aaff226
|
|
BLAKE2b-256 checksum How to use checksums |
8234ec0c80bb23d2b895b02f3dd9a03bb200b9ce44fbbdbda3b9cd4711f416c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2
|