{"id":16251535,"url":"https://github.com/pfalcon/pyastinterp","last_synced_at":"2025-03-19T20:30:51.846Z","repository":{"id":139749033,"uuid":"228240608","full_name":"pfalcon/pyastinterp","owner":"pfalcon","description":"Python AST interpreter (aka tree-walking interpreter) in Python. Aka meta-circular interpreter.","archived":false,"fork":false,"pushed_at":"2020-12-23T15:44:49.000Z","size":41,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T20:46:40.215Z","etag":null,"topics":["interpreter","meta-circular","metacircular","metacircular-interpreter","pycopy","python"],"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/pfalcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-15T19:38:10.000Z","updated_at":"2024-08-02T18:52:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed0e54bb-5e9c-43d1-b924-5eb4e3727d30","html_url":"https://github.com/pfalcon/pyastinterp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpyastinterp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpyastinterp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpyastinterp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpyastinterp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfalcon","download_url":"https://codeload.github.com/pfalcon/pyastinterp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244014108,"owners_count":20383716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["interpreter","meta-circular","metacircular","metacircular-interpreter","pycopy","python"],"created_at":"2024-10-10T15:10:30.971Z","updated_at":"2025-03-19T20:30:51.563Z","avatar_url":"https://github.com/pfalcon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyastinterp\n===========\n\nThis is an AST interpreter (also known as tree-walking interpreter) for\nthe Python programming language, written in Python itself. It is thus\na meta-circular interpreter. While Python implementations of a Python VM\n(i.e. bytecode interpreters) are relatively well known (starting with\nPyPy), AST interpreters are much less common beyond those which implement\na very limited subset of the syntax.\n\nPyastinterp strives to fulfil 2 goals:\n\n1. Be as complete as possible (and see how much effort that takes and\n   if there're any limits).\n2. Yet be as minimal as possible, avoiding useless boilerplate and\n   reimplementing what may be already available.\n\nFirst goal is pretty obvious: ideally, we'd like Pyastinterp to be able\nto interpret (run) any application a native Python interpreter can.\n\nSecond goal is rooted in many reasons. To start with, Pyastinterp is\na spiritual part of the [Pycopy](https://github.com/pfalcon/pycopy)\nproject, whose goal is the development of minimalist Python-compatible\necosystem. Besides, \"bloated\" meta-circular interpreters are well out\nthere (the same PyPy) - there's lack on the opposite side of spectrum.\nPyastinterp is also intended to be a \"teaching\" and \"for-research\"\nproject. Surely, it's much easier to learn and reuse/repurpose a small,\nrather than large, project. These last requirements however also put\nbounds on \"minimality\": `pyastinterp` tries to have a clear focus\n(AST interpretation) and avoid unneeded boilerplate, but not be\nobfuscated, and actually tries to be clear and easily hackable (provide\nsome reusable infrastructure), even at the expense of somewhat less\noptimality/performance.\n\nTo achieve the goals of minimality, `pyastinterp` does following:\n\n1. Is concerned with syntax, not semantics (largely).\n2. That means that it tries to interpret Python AST tree, but\n   relies on the underlying Python runtime to implement the actual\n   operations (semantics). In some cases `pyastinterp` actually\n   has to deal with runtime semantics, but the point is that it\n   should be done only when there's no other choice (i.e. rarely).\n3. This in particular means that `pyastinterp` itself requires a\n   (pretty) full Python implementation to run, it's not the case\n   that it's written in \"some subset of Python\". (Contrast that\n   with e.g. PyPy's RPython, which is a Python subset language,\n   in which interpreters are written).\n4. Another consequence is that there's no semantic separation\n   between \"metalevel\" (level of the interpreter) and target\n   application level. This is again unlike PyPy, where 2 are explicitly\n   separated. Lack of separation allows to save on \"marshalling\"\n   values between the 2 levels, but also make it possible to have\n   \"leaks\" between levels, e.g. unexpected and unhandled exception\n   in the interpreter to be delivered to the application, causing\n   havoc and confusion. Pyastinterp's response to this concern\n   is a pledge that there shouldn't be such unhandled interpreter-level\n   exceptions. Of course, catching all such cases may take quite\n   a lot of testing and debugging, and fixing them may affect code\n   minimality and clarity. We'll see how it goes.\n5. However, due to choices described above, implementation of many\n   syntactic constructs is very clear, concise, and isomorphic\n   between the target and meta levels. See e.g. how \"if\" statement\n   is implemented: the implementation looks almost exactly how the\n   usage of the \"if\" statement is.\n\n\nSupported Python subset\n-----------------------\n\nPyastinterp should implement almost all Python3.5 features, stopping\nat generators, which are not that easy to implement in a tree-walking\ninterpreter. It also does not include import hook, so the imported\nmodules are interpreted by the underlying Python VM, not by\nPyastinterp.\n\n\nRunning\n-------\n\nQuick way to run something interesting:\n\n    wget https://raw.githubusercontent.com/python/cpython/3.6/Lib/test/pystone.py\n    python3 -m astinterp pystone.my 10000\n\nYou can pass any other script on the command line and see how it goes.\n\n\nCredits and licensing\n---------------------\n\nPyastinterp is (c) [Paul Sokolovsky](https://github.com/pfalcon) and\nis released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfalcon%2Fpyastinterp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfalcon%2Fpyastinterp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfalcon%2Fpyastinterp/lists"}