Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martmists-gh/bytecodeoptimizer
https://github.com/martmists-gh/bytecodeoptimizer
bytecode bytecode-manipulation python3 pythontools
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/martmists-gh/bytecodeoptimizer
- Owner: Martmists-GH
- License: mit
- Created: 2019-11-21T00:26:33.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-25T13:43:30.000Z (about 5 years ago)
- Last Synced: 2024-11-04T20:06:39.141Z (about 2 months ago)
- Topics: bytecode, bytecode-manipulation, python3, pythontools
- Language: Python
- Size: 15.6 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BytecodeOptimizer
This library provides methods to optimize your code automatically.
### Usage
```py
# __future imports above here
from bytecode_optimizer import enable, optimized, Flags
Flags.TAIL_CALL_OPTIMIZATION = False # Disable TCO# Optimize a function you made yourself ...
# this function optimizes to `return 8`, removing all variables
@optimized
def abc():
x = 2
b = 3
if x:
x = 7
y = 1
return x + y# ... or optimize an entire module:
enable()
# all other imports and code below here
```Note that it will not optimize any code in the current scope with `enable()`, only modules imported after the enable call.