[pypy-svn] r77051 - in pypy/branch/fast-forward/pypy: interpreter module/sys

afa at codespeak.net afa at codespeak.net
Mon Sep 13 23:32:04 CEST 2010


Author: afa
Date: Mon Sep 13 23:32:03 2010
New Revision: 77051

Modified:
   pypy/branch/fast-forward/pypy/interpreter/executioncontext.py
   pypy/branch/fast-forward/pypy/module/sys/__init__.py
   pypy/branch/fast-forward/pypy/module/sys/vm.py
Log:
Implement sys.getprofile()


Modified: pypy/branch/fast-forward/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/executioncontext.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/executioncontext.py	Mon Sep 13 23:32:03 2010
@@ -218,6 +218,9 @@
         else:
             self.setllprofile(app_profile_call, w_func)
 
+    def getprofile(self):
+        return self.w_profilefuncarg
+
     def setllprofile(self, func, w_arg):
         if func is not None:
             if w_arg is None:

Modified: pypy/branch/fast-forward/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/sys/__init__.py	(original)
+++ pypy/branch/fast-forward/pypy/module/sys/__init__.py	Mon Sep 13 23:32:03 2010
@@ -51,6 +51,7 @@
         'exc_clear'             : 'vm.exc_clear', 
         'settrace'              : 'vm.settrace',
         'setprofile'            : 'vm.setprofile',
+        'getprofile'            : 'vm.getprofile',
         'call_tracing'          : 'vm.call_tracing',
         
         'executable'            : 'space.wrap("py.py")', 

Modified: pypy/branch/fast-forward/pypy/module/sys/vm.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/sys/vm.py	(original)
+++ pypy/branch/fast-forward/pypy/module/sys/vm.py	Mon Sep 13 23:32:03 2010
@@ -112,6 +112,15 @@
 and return.  See the profiler chapter in the library manual."""
     space.getexecutioncontext().setprofile(w_func)
 
+def getprofile(space):
+    """Set the profiling function.  It will be called on each function call
+and return.  See the profiler chapter in the library manual."""
+    w_func = space.getexecutioncontext().getprofile()
+    if w_func is not None:
+        return w_func
+    else:
+        return space.w_None
+
 def call_tracing(space, w_func, w_args):
     """Call func(*args), while tracing is enabled.  The tracing state is
 saved, and restored afterwards.  This is intended to be called from



More information about the Pypy-commit mailing list