Author: Armin Rigo <[email protected]>
Branch:
Changeset: r71098:a1486cf0b55f
Date: 2014-04-30 20:39 +0200
http://bitbucket.org/pypy/pypy/changeset/a1486cf0b55f/
Log: Hack cProfile.py to avoid creating explicitly the main module's
dictionary. Instead, use new.module() and implicitly get it by
reading the __dict__.
This should fix one source of slow-down for cProfile on PyPy.
diff --git a/lib-python/2.7/cProfile.py b/lib-python/2.7/cProfile.py
--- a/lib-python/2.7/cProfile.py
+++ b/lib-python/2.7/cProfile.py
@@ -161,7 +161,7 @@
# ____________________________________________________________
def main():
- import os, sys
+ import os, sys, new
from optparse import OptionParser
usage = "cProfile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
parser = OptionParser(usage=usage)
@@ -184,12 +184,10 @@
sys.path.insert(0, os.path.dirname(progname))
with open(progname, 'rb') as fp:
code = compile(fp.read(), progname, 'exec')
- globs = {
- '__file__': progname,
- '__name__': '__main__',
- '__package__': None,
- }
- runctx(code, globs, None, options.outfile, options.sort)
+ mainmod = new.module('__main__')
+ mainmod.__file__ = progname
+ mainmod.__package__ = None
+ runctx(code, mainmod.__dict__, None, options.outfile, options.sort)
else:
parser.print_usage()
return parser
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit