Remix.run Logo
dkersten an hour ago

Once upon a time I tried to write such a decorator too in python 2.x and the byteplay bytecode disassembler library. I was trying to do the conversion at the bytecode level instead of transforming the AST. I believe I got as far as detecting simple self recursive functions, but never actually managed to implement the actual transformation.

lioeters 27 minutes ago | parent [-]

That is an ambitious idea, and I applaud anyone who attempts such heights even if it turned out to be impractical.

OP's approach is surprisingly straight forward, only a few hundred lines.

https://github.com/raaidrt/tacopy/blob/main/src/tacopy/trans...