[pypy-svn] r68944 - pypy/trunk/pypy/module/__builtin__

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Nov 3 17:08:28 CET 2009


Author: cfbolz
Date: Tue Nov  3 17:08:27 2009
New Revision: 68944

Added:
   pypy/trunk/pypy/module/__builtin__/interp_inspect.py   (contents, props changed)
Modified:
   pypy/trunk/pypy/module/__builtin__/__init__.py
   pypy/trunk/pypy/module/__builtin__/app_inspect.py
Log:
Move the implementation of locals and globals to interp-level, to not force the
frame chain in the case of the JIT.


Modified: pypy/trunk/pypy/module/__builtin__/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/__init__.py	(original)
+++ pypy/trunk/pypy/module/__builtin__/__init__.py	Tue Nov  3 17:08:27 2009
@@ -32,8 +32,6 @@
         # redirected to functional.py, applevel version
         # is still needed and should stay where it is.
         'sorted'        : 'app_functional.sorted',
-        'globals'       : 'app_inspect.globals',
-        'locals'        : 'app_inspect.locals',
         'vars'          : 'app_inspect.vars',
         'dir'           : 'app_inspect.dir',
 
@@ -110,6 +108,9 @@
         'classmethod'   : 'descriptor.ClassMethod',
         'property'      : 'descriptor.W_Property',
 
+        'globals'       : 'interp_inspect.globals',
+        'locals'        : 'interp_inspect.locals',
+
     }
 
     def pick_builtin(self, w_globals):

Modified: pypy/trunk/pypy/module/__builtin__/app_inspect.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/app_inspect.py	(original)
+++ pypy/trunk/pypy/module/__builtin__/app_inspect.py	Tue Nov  3 17:08:27 2009
@@ -5,16 +5,9 @@
 
 import sys
 
-def globals():
-    "Return the dictionary containing the current scope's global variables."
-    return sys._getframe(0).f_globals
-
-def locals():
-    """Return a dictionary containing the current scope's local variables.
-Note that this may be the real dictionary of local variables, or a copy."""
-    return sys._getframe(0).f_locals
-
 def _caller_locals(): 
+    # note: the reason why this is working is because the functions in here are
+    # compiled by geninterp, so they don't have a frame
     return sys._getframe(0).f_locals 
 
 def vars(*obj):

Added: pypy/trunk/pypy/module/__builtin__/interp_inspect.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/__builtin__/interp_inspect.py	Tue Nov  3 17:08:27 2009
@@ -0,0 +1,12 @@
+
+def globals(space):
+    "Return the dictionary containing the current scope's global variables."
+    ec = space.getexecutioncontext()
+    return ec.gettopframe_nohidden().w_globals
+
+def locals(space):
+    """Return a dictionary containing the current scope's local variables.
+Note that this may be the real dictionary of local variables, or a copy."""
+    ec = space.getexecutioncontext()
+    return ec.gettopframe_nohidden().getdictscope()
+



More information about the Pypy-commit mailing list