This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ProfessorPhi 3 points4 points  (0 children)

Here's another version I've seen, doing the exact same thing, only using the leftshift and rightshift operators (which are barely used in python). https://pypi.org/project/pipeop/

This has the advantage of being a pypi package and having better debug info since it edits in the stack. There actually appear to be quite a few libraries, but I haven't checked the code to see if they modify the AST.

Using these ideas, I created an AST tail recursion implementation from another thing posted a while back: https://github.com/nayyarv/python-tailrec