3 ms·
Could this be used to create a macro system for python?
by typon 8y ago
Could this be used to create a macro system for python?
- hathawsh 8y agoI'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
- klibertp 8y agoAnother one? https://github.com/lihaoyi/macropy https://github.com/lihaoyi/macropy