{"id":20906556,"url":"https://github.com/xia-mc/pylang","last_synced_at":"2026-01-24T03:38:58.910Z","repository":{"id":258779494,"uuid":"861790374","full_name":"xia-mc/Pylang","owner":"xia-mc","description":"A Python Code Optimizer Based on Static Analysis.","archived":false,"fork":false,"pushed_at":"2024-12-04T07:35:06.000Z","size":144,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T23:05:13.605Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xia-mc.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":"2024-09-23T14:15:36.000Z","updated_at":"2024-12-04T07:35:10.000Z","dependencies_parsed_at":"2024-10-24T14:45:10.917Z","dependency_job_id":"950532fd-d7fb-4044-97ab-7ad613f7c882","html_url":"https://github.com/xia-mc/Pylang","commit_stats":null,"previous_names":["xia-mc/pylang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xia-mc%2FPylang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xia-mc%2FPylang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xia-mc%2FPylang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xia-mc%2FPylang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xia-mc","download_url":"https://codeload.github.com/xia-mc/Pylang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253889408,"owners_count":21979623,"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":[],"created_at":"2024-11-18T13:34:09.044Z","updated_at":"2026-01-24T03:38:58.882Z","avatar_url":"https://github.com/xia-mc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pylang\n\n[简体中文](https://github.com/xia-mc/Pylang/blob/master/README_CN.md)\n\n\u003e [!NOTE]\n\u003e Pylang is in an early development stage. Expect frequent errors, crashes, and poor performance. Please avoid using it\n\u003e in any projects.\n\n\n**Pylang** is a Python code optimizer based on Abstract Syntax Tree (AST) that performs static analysis to improve code\nefficiency. It is designed to allow Python developers to write clean, maintainable code while benefiting from\noptimizations that reduce runtime overhead.\n\n## Features\n\n- **Constant Folding**: Evaluate constant expressions at compile time to reduce runtime calculations.\n- **Loop Unfolding**: Unroll loops to reduce overhead, improving performance for certain scenarios.\n- **Unused Variable Remover**: Automatically remove unused variables to clean up code and reduce memory usage.\n\n## TODO\n\n- [ ] **Variable Inlining**: Automatically inline variables where applicable for improved performance.\n- [ ] **Advanced Decorators**: Add support for decorators like `@inline`, `@const`, and `@native` for advanced\n  optimizations.\n- [ ] **Releases**: Packaging the project with proper release notes and binaries for easier distribution.\n- [ ] **Documentation**: Detailed API documentation and examples to guide developers in integrating Pylang into their\n  projects.\n\n## Getting Started\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/xia-mc/Pylang.git\n    ```\n2. Install dependencies:\n    ```bash\n    pip install -r requirements.txt\n    ```\n3. Run the optimizer on your Python project (Python 3.7+ require):\n    ```bash\n    python Pylang.py \u003cflags\u003e\n    ```\n\n### Flags:\n\n- F \u003cfilepath\u003e/D \u003cdirpath\u003e: Path to the file to be optimized.\n- O \u003cdirpath\u003e: Path to the output folder.\n- O0/O1/O2/O3: Optimize level.\n    - O0: Only format codes to make smaller.\n    - O1: Do some simple derivations and the functionality of the program will not be affected.\n    - O2: Do more aggressive optimizations, the behavior of certain functions (like exec) may change.\n- tofile: Write logs to `latest.log` instead of printing to stdout.\n  example:\n\n```bash\npython ./src/main/Pylang.py -D ./src/test -O2\n```\n\n## Contribution\n\nFeel free to submit issues, pull requests, or feature requests to help improve Pylang. Contributions and feedback are\ngreatly appreciated!\n\n## Acknowledgements\n\nThis project would not have been possible without the help of the following tools and platforms:\n\n- **[PyCharm](https://www.jetbrains.com/pycharm/)**: For providing an excellent IDE that made the development process\n  smooth and efficient.\n- **[CPython](https://github.com/python/cpython)**: The core of Python itself, which made this project possible by\n  providing the powerful runtime environment on which Pylang is based.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxia-mc%2Fpylang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxia-mc%2Fpylang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxia-mc%2Fpylang/lists"}