{"id":22018802,"url":"https://github.com/thautwarm/moshmosh","last_synced_at":"2026-03-05T07:35:49.609Z","repository":{"id":45200122,"uuid":"196604714","full_name":"thautwarm/moshmosh","owner":"thautwarm","description":"An amazing syntax extension system in pure Python, the way to coding efficiency. ","archived":false,"fork":false,"pushed_at":"2022-01-01T03:36:20.000Z","size":1633,"stargazers_count":108,"open_issues_count":8,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-27T18:37:07.073Z","etag":null,"topics":["extension","lightweighted","macro","no-evilness","pattern-matching","syntax"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thautwarm.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-12T15:39:55.000Z","updated_at":"2024-07-18T05:09:16.000Z","dependencies_parsed_at":"2022-09-18T04:41:40.762Z","dependency_job_id":null,"html_url":"https://github.com/thautwarm/moshmosh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/thautwarm/moshmosh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2Fmoshmosh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2Fmoshmosh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2Fmoshmosh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2Fmoshmosh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thautwarm","download_url":"https://codeload.github.com/thautwarm/moshmosh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thautwarm%2Fmoshmosh/sbom","scorecard":{"id":876893,"data":{"date":"2025-08-11","repo":{"name":"github.com/thautwarm/moshmosh","commit":"12435ac6288e88b42ea13d59825b90b37e297f38"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T06:23:13.278Z","repository_id":45200122,"created_at":"2025-08-24T06:23:13.278Z","updated_at":"2025-08-24T06:23:13.278Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30114316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","lightweighted","macro","no-evilness","pattern-matching","syntax"],"created_at":"2024-11-30T05:14:13.221Z","updated_at":"2026-03-05T07:35:49.584Z","avatar_url":"https://github.com/thautwarm.png","language":"Python","readme":"\n# Notes\n\nThis project is now under inactive development.\n\nWant to take over? Email me.\n\n# Moshmosh\n\n[![Build](https://travis-ci.com/thautwarm/moshmosh.svg?branch=master)](https://travis-ci.com/thautwarm/moshmosh) [![Support](https://img.shields.io/badge/PyPI-\u0026nbsp;3\\.5~3\\.7-Orange.svg?style=flat)](https://pypi.org/project/moshmosh-base) [![codecov](https://codecov.io/gh/thautwarm/moshmosh/branch/master/graph/badge.svg)](https://codecov.io/gh/thautwarm/moshmosh)\n\nAn advanced syntax extension system implemented in pure python.\n\n```\npip install -U moshmosh-base --no-compile\n```\n\nNote that `--no-compile` is required.\n\n# Preview\n\n## Working with IPython\n\nYou should copy [moshmosh_ipy.py](https://raw.githubusercontent.com/thautwarm/moshmosh/master/moshmosh_ipy.py)\nto `$USER/.ipython/profile_default/startup/`.\n\nIf this directory does not exist, use command `ipython profile create` to instantiate.\n\nSome examples about pattern matching, pipelines and quick lambdas:\n\n![IPython example 1](https://raw.githubusercontent.com/thautwarm/moshmosh/master/static/img1.png)\n\nSome examples about the scoped operators:\n\n![IPython example 2](https://raw.githubusercontent.com/thautwarm/moshmosh/master/static/img2.png)\n\n## Working with regular Python files\n\nImport `moshmosh` in your main module:\n\n![Main.py](https://raw.githubusercontent.com/thautwarm/moshmosh/master/static/main.png)\n\nThen, in `mypackage.py`, start coding with a pragma comment `# moshmosh?`, then you can use moshmosh extension system.\n\n![Upack.py](https://raw.githubusercontent.com/thautwarm/moshmosh/master/static/upack.png)\n\n## Case Study : Pattern Matching\n\nThe matching protocol which stems from Python-ideas mailing list is introduced in,\nwhich means you can define your own patterns conveniently.\nThe link is [here](https://mail.python.org/pipermail/python-ideas/2015-April/032920.html).\n\n```python\n# moshmosh?\n# +pattern-matching\n\nclass GreaterThan:\n    def __init__(self, v):\n        self.v = v\n\n    def __match__(self, cnt: int, to_match):\n        if isinstance(to_match, int) and cnt is 0 and to_match \u003e self.v:\n            return () # matched\n        # 'return None' indicates 'unmatched'\n\nwith match(114, 514):\n    if (GreaterThan(42)() and a, b):\n        print(b, a)\n# 514 114\n```\n\nNote that the matching clauses should be exhaustive,\notherwise, a `moshmosh.extensions.pattern_matching.runtime.NotExhaustive`\nmight get raised.\n\nThe supported Patterns are listed here, which is\nof course much more powerful than most programming languages.\n\n- And pattern: `pat1 and pat2 and pat3 ...`\n- Or pattern: `pat1 or pat2 or pat3...`\n- Pin pattern: `pin(value)`, this is quite useful. See [Elixir Pin Operator](https://elixir-lang.org/getting-started/pattern-matching.html#the-pin-operator)\n- Literal pattern: `1, \"str\", 1+2j, (1, 2)`\n- As pattern: `a, var`\n- Wildcard: `_`\n- Guard: `when(cond1, cond2, cond3)`\n- Nested patterns:\n    - Tuple: `(pat1, pat2, pat3), (pat1, *pat2, pat3)`\n    - List:  `[pat1, pat2, pat3], [pat1, *pat2, pat3]`\n    - Recogniser: `Cons(pat1, pat2, pat3)`, note that,\n        the function `Cons.__match__(\u003cn arg\u003e, value_to_match)` is exact the protocol.\n\nThe pattern matching should be more efficient than those hand-written codes without\nugly optimizations.\n\nBesides, Moshmosh's pattern matching is orders of magnitude faster than\nany other alternatives.\n\n## Case Study : Template-Python\n\nThis is relatively a simple quasiquote implementation, inspired by MetaOCaml.\nIt does not support manual splices or nested quotations, but the function arguments\nare automatically spliced.\n\n```python\n# moshmosh?\n# +template-python\n\n@quote\ndef f(x):\n    x + 1\n    x = y + 1\n\nfrom moshmosh.ast_compat import ast\nfrom astpretty import pprint\n\nstmts = f(ast.Name(\"a\"))\npprint(ast.fix_missing_locations(stmts[0]))\npprint(ast.fix_missing_locations(stmts[1]))\n\n# =\u003e\nExpr(\n    lineno=7,\n    col_offset=4,\n    value=BinOp(\n        lineno=7,\n        col_offset=4,\n        left=Name(lineno=7, col_offset=4, id='a', ctx=Load()),\n        op=Add(),\n        right=Num(lineno=7, col_offset=8, n=1),\n    ),\n)\nAssign(\n    lineno=8,\n    col_offset=4,\n    targets=[Name(lineno=8, col_offset=4, id='a', ctx=Store())],\n    value=BinOp(\n        lineno=8,\n        col_offset=8,\n        left=Name(lineno=8, col_offset=8, id='y', ctx=Load()),\n        op=Add(),\n        right=Num(lineno=8, col_offset=12, n=1),\n    ),\n)\n```\n\n## Case Study: Lazy Import\n\n```python\n# moshmosh?\n# +lazy-import\nimport numpy as np\n# -lazy-import\n\n# in fact numpy is not imported here,\n# and once you use it, it gets imported.\n\ndef arr10():\n    # The first time call\n    # arr10 will enforce the import of numpy.\n    return np.zeros(10)\n```\n\nAfter the lazy modules are actually imported, there's\nno overhead to access their members.\n\nHowever, please only import modules when using `lazy-import`.\n\nThe use case is about the necessary cross-import when you want to\norganise your codebase in a more fine-grained way.\n\n\n## Acknowledgements\n\n- [future-fstrings](https://github.com/asottile/future-fstrings)\n- Pattern matching in Python\n    - [older implementations](http://www.grantjenks.com/docs/patternmatching/#alternative-packages)\n    - search \"pattern matching\" at [Python-ideas](https://mail.python.org/archives/list/python-ideas@python.org/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthautwarm%2Fmoshmosh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthautwarm%2Fmoshmosh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthautwarm%2Fmoshmosh/lists"}