3 ms·
I'm sure it could be used that way, but the compile() function and the ast library (part of the stdlib) are a more direct way to create a macro system: https:/
by hathawsh 8y ago
I'm sure it could be used that way, but the compile() function and the ast library (part of the stdlib) are a more direct way to create a macro system:
https://docs.python.org/3/library/ast.html https://docs.python.org/3/library/ast.html
I've built macros using the ast library before and it works, but I also found I could adjust my DSL's grammar just a bit and express the same thing with ordinary Python code. That's why Python macro systems rarely gain much traction.
BTW Bowler looks cool. I expect to try it next time I do a big refactor.
- makmanalp 8y agoFor bytecode level transformations rather than AST level: https://github.com/llllllllll/codetransformer https://github.com/llllllllll/codetransformer