Victor Stinner wrote:
Le mar. 19 nov. 2019 à 22:12, Pablo Galindo Salgado pablogsal@gmail.com a écrit :
Float infinity is replaced with 1e309. Again, maybe someone wants to render this differently? It sounds like an arbitrary choice (which "works" as expected). That is not true. float('inf') is rendered as float('inf´): Unparser(ast.parse("float('inf')")) float('inf') I was thinking at: Unparser(ast.parse("1e999")) 1e309 Maybe just move the constant as a class attribute, so it can be overriden in a subclass? I would prefer to keep a separated module, like "import ast.unparse" or "import unparse". Why? I think ast.unparse is a natural fit. It will likely be only one function exposed. It's mostly to minimize the number of imports on "import ast". unparse requires extra imports like tokenize which has also tons of dependencies.
Why are you specifically worried about that? If you're doing AST transformations you're probably either doing it offline/AOT or you're already doing extra processing which means you probably aren't stressing over how quickly an initial import will take if this is all worries surrounding doing live AST transformations on the way to writing out bytecode or loading a module on the fly.
Victor Night gathers, and now my watch begins. It shall not end until my death.