Source

astoptimizer / site.patch

Full commit
diff -r 95fb7b66107e Lib/site.py
--- a/Lib/site.py	Fri Mar 22 00:06:20 2013 +0100
+++ b/Lib/site.py	Fri Mar 22 02:07:40 2013 +0100
@@ -581,6 +581,21 @@ def main():
     if ENABLE_USER_SITE:
         execusercustomize()
 
+    try:
+        import astoptimizer
+        config = astoptimizer.Config()
+        def ignore_log(message):
+            pass
+        config.enable_all_optimizations()
+        config.remove_almost_dead_code = True
+        config.warning_func = ignore_log
+    except ImportError:
+        pass
+    else:
+        def asthook(tree, filename):
+            return astoptimizer.optimize_ast(tree, config, filename)
+        sys.setasthook(asthook)
+
 # Prevent edition of sys.path when python was started with -S and
 # site is imported later.
 if not sys.flags.no_site: