Skip to content

🆒 Metaprogramming tools for ast manipulation, creating rewritable functions, that are aware of their 1️⃣ functional equivalence, 2️⃣ computability, 3️⃣ asymptotic complexity and 4️⃣ problems being solved

radixvinni/astricks

 
 

Repository files navigation

metafunc.py

Function wrapper for decompiling and ast manipulation of wrapped function. Can be used as decorator with any python function or lambda.

>>> Mf(lambda x:x+1)
#-5599708371849146885
def f(x):
    return (x + 1)

rewrite_rules.py

Defines NodeTransformers to modify ast

>>> b=Mf(lambda y:y+1)
>>> RewriteNames({'y':'x'}).visit(b.ast)
<_ast.FunctionDef object at 0x7f5e03f5f350>
>>> b
#-5599708371849146885
def f(x):
    return (x + 1)
>>> b==a
True

About

🆒 Metaprogramming tools for ast manipulation, creating rewritable functions, that are aware of their 1️⃣ functional equivalence, 2️⃣ computability, 3️⃣ asymptotic complexity and 4️⃣ problems being solved

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%