A Python-inspired interpreter with real-time code analysis and optimization suggestions
Project description
OptiLang
A Python-inspired interpreter with real-time code analysis and optimization suggestions
๐ฏ Project Overview
OptiLang is an educational interpreter for a Python-like language (PyLite) that provides:
- Real-time code execution with line-by-line profiling
- Optimization suggestions based on detected anti-patterns
- Quantitative scoring (0-100) for code quality
- Pattern detection for 8+ common performance issues
๐ Quick Start
Installation
pip install optilang
Basic Usage
from optilang import execute, analyze
# Execute PyLite code
result = execute("""
def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
print(factorial(5))
""")
print(result.output) # "120"
print(f"Execution time: {result.execution_time}ms")
# Analyze code for optimizations
report = analyze("""
for i in range(100):
for j in range(100):
result = i * j
""")
print(f"Optimization Score: {report.optimization_score}/100")
for suggestion in report.suggestions:
print(f"Line {suggestion.line}: {suggestion.description}")
๐๏ธ Architecture
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Lexer โ -> โ Parser โ -> โ Executor โ -> โ Profiler โ
โ (Tokens) โ โ (AST) โ โ (Runtime)โ โ (Metrics)โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ โ
v v
โโโโโโโโโโโโ โโโโโโโโโโโโ
โOptimizer โ โ Scorer โ
โ(Patterns)โ โ (0-100) โ
โโโโโโโโโโโโ โโโโโโโโโโโโ
๐ Features
Current (v0.1.0)
- Lexical analysis (tokenization)
- Syntax parsing (AST generation)
- Code execution (variables, functions, control flow)
- Basic profiling (execution time, line counts)
Planned
- Advanced profiling (memory usage, call graphs)
- 8+ optimization patterns
- ML-based suggestion ranking (optional)
- Optimization score calculation
- Comprehensive documentation
๐ ๏ธ Development Setup
# Clone repository
git clone https://github.com/Sthamanik/optilang.git
cd optilang
# Create virtual environment
conda create -n optilang python -y
conda activate optilang
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black optilang/
# Type checking
mypy optilang/
# Linting
flake8 optilang/
๐ Documentation
- User Guide: Coming soon
- API Reference: Coming soon
- Contributing Guide: See CONTRIBUTING.md
- Changelog: See CHANGELOG.md
๐งช Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=optilang --cov-report=html
# View coverage report
open htmlcov/index.html # Linux/Mac
# or start htmlcov/index.html on Windows
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฅ Team
๐ง Contact
For questions or feedback:
- Email: shresthamanik1820@gmail.com
- Issues: GitHub Issues
โญ Star this repository if you find it useful!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optilang-0.1.0.tar.gz.
File metadata
- Download URL: optilang-0.1.0.tar.gz
- Upload date:
- Size: 38.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99710da7bfc792bf1af0debcdbc5bd65567f0ee1643c0f9486bc1854e88a3f11
|
|
| MD5 |
35dd4de9ac7943715ce851ca15c9a90e
|
|
| BLAKE2b-256 |
89b15784809f8e8ca3829c3cb9bbda61936afa83cfdb8ea0b79ba739f4225061
|
File details
Details for the file optilang-0.1.0-py3-none-any.whl.
File metadata
- Download URL: optilang-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
789ee2c62df0c5881c50d9b38680a32840876846be4739671b9e33096d14964d
|
|
| MD5 |
4b6e0ae111eadae747d80fe0734fa979
|
|
| BLAKE2b-256 |
dc4df310c09d7605894f3a05a611c40567ae5cc0ea05ae546cb943447fa704af
|