[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2015-03-28 Thread Brett Cannon
Brett Cannon added the comment: The closing of this issue inspired me to think of a better way to do this, and I think providing something in importlib.util that accepted a NodeTransformer as an argument to a function that compiled source files to bytecode files would fill this issue thanks to

[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2015-03-18 Thread STINNER Victor
STINNER Victor added the comment: I'm not more interested to work on my astoptimizer project, and nobody looks to need sys.setasthook(), so I prefer to close the issue. -- resolution: -> out of date status: open -> closed ___ Python tracker

[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2013-03-22 Thread Brett Cannon
Brett Cannon added the comment: And that's fine as it allows for more explicit control over what gets optimized. Basically if there is a global hook directly into the compiler there needs to be more control over detecting it's being optimized, what to do about .pyo files, etc. At least at the

[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2013-03-22 Thread STINNER Victor
STINNER Victor added the comment: > This is unnecessary. Your change only concerns imports. eval() and compile() cannot be hooked using your method. 2013/3/22 Brett Cannon : > > Brett Cannon added the comment: > > This is unnecessary. I added the source_to_code() method > (http://docs.python.o

[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2013-03-22 Thread Brett Cannon
Brett Cannon added the comment: This is unnecessary. I added the source_to_code() method (http://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader.source_to_code) to loaders to explicitly handle this case. -- ___ Python tracker

[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2013-03-21 Thread STINNER Victor
STINNER Victor added the comment: enable_astoptimizer.patch: example of usage of the new function, you can use it to try astoptimizer. -- Added file: http://bugs.python.org/file29540/enable_astoptimizer.patch ___ Python tracker

[issue17515] Add sys.setasthook() to allow to use a custom AST optimizer

2013-03-21 Thread STINNER Victor
New submission from STINNER Victor: I wrote an optimizer rewriting the AST to implement various optimizatoions: https://bitbucket.org/haypo/astoptimizer To be able to use it, or use any other kind of AST transformation, I propose to add a new sys.setasthook() function to set a custom AST hook.