ast_tools
ast_tools copied to clipboard
Toolbox for working with the Python AST
This code: ```python import inspect from ast_tools.passes import apply_ast_passes, ssa, loop_unroll from ast_tools.macros import unroll class Foo: def __init__(self): self.x = [i for i in range(4)] @apply_ast_passes([loop_unroll(), ssa()]) def __call__(self,...
Given a trivial code example: ```python def some_fn(): for i in range(100): result += x * i return result ``` unrolled in batches of say 10 iterations: ```python def some_fn():...
Ive discovered a bug (maybe undocumented requirement is a better term) that is hard to resolve. Currently given: ```Python @wrapper2 @end @... @begin @wrapper1 def foo(...): ... ``` `end` will...
I was wondering if its possible to support multiple passes of loop unrolling. This is the type of nested loop I want to unroll: ``` def test_nested_unroll(): z = 3...
The following example will produce a phi node for 'a' even thought it is unneeded. This causes problems when the types of 'a' in each branch are different ``` def...
`unroll_loops` should check that the loop doesn't have a break and raise an error if it does (or should have the correct behavior).
In debug mode we should track what node(s) caused another node to exists if possible. For example ``` node = ast.BoolOp(...) tree = ast.Ast(..., node, ...) metadata = {} env...