[pypy-svn] r34501 - in pypy/dist: demo pypy/config pypy/doc pypy/module/pypymagic pypy/objspace pypy/objspace/test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Nov 11 19:58:00 CET 2006


Author: cfbolz
Date: Sat Nov 11 19:57:56 2006
New Revision: 34501

Modified:
   pypy/dist/demo/fibonacci.py
   pypy/dist/demo/sharedref.py
   pypy/dist/pypy/config/pypyoption.py
   pypy/dist/pypy/doc/getting-started.txt
   pypy/dist/pypy/module/pypymagic/__init__.py
   pypy/dist/pypy/objspace/test/test_thunkobjspace.py
   pypy/dist/pypy/objspace/thunk.py
Log:
move thunk, is_thunk and become to pypymagic (if the thunk object space is
used)


Modified: pypy/dist/demo/fibonacci.py
==============================================================================
--- pypy/dist/demo/fibonacci.py	(original)
+++ pypy/dist/demo/fibonacci.py	Sat Nov 11 19:57:56 2006
@@ -9,8 +9,8 @@
 """
 
 try:
-    thunk    # only available in 'py.py -o thunk'
-except NameError:
+    from pypymagic import thunk    # only available in 'py.py -o thunk'
+except ImportError:
     print __doc__
     raise SystemExit(2)
 

Modified: pypy/dist/demo/sharedref.py
==============================================================================
--- pypy/dist/demo/sharedref.py	(original)
+++ pypy/dist/demo/sharedref.py	Sat Nov 11 19:57:56 2006
@@ -35,6 +35,7 @@
 """
 
 import sys, marshal
+from pypymagic import thunk, become
 from socket import *
 from select import select
 

Modified: pypy/dist/pypy/config/pypyoption.py
==============================================================================
--- pypy/dist/pypy/config/pypyoption.py	(original)
+++ pypy/dist/pypy/config/pypyoption.py	Sat Nov 11 19:57:56 2006
@@ -24,7 +24,8 @@
                      ["std", "flow", "logic", "thunk", "cpy", "dump"], "std",
                      requires = {
                          "thunk": [("objspace.geninterp", False)],
-                         "logic": [("objspace.geninterp", False)],
+                         "logic": [("objspace.geninterp", False),
+                                   ("objspace.usemodules._stackless", True)],
                      },
                      cmdline='--objspace -o'),
 

Modified: pypy/dist/pypy/doc/getting-started.txt
==============================================================================
--- pypy/dist/pypy/doc/getting-started.txt	(original)
+++ pypy/dist/pypy/doc/getting-started.txt	Sat Nov 11 19:57:56 2006
@@ -246,6 +246,7 @@
     cd pypy/bin
     python py.py -o thunk
 
+    >>>> from pypymagic import thunk
     >>>> def longcomputation(lst):
     ....     print "computing..."
     ....     return sum(lst)
@@ -286,7 +287,7 @@
 Try it out::
 
     cd pypy/bin
-    python py.py -o logic --usemodules=_stackless
+    python py.py -o logic
 
     >>>> X = newvar()         # a logic variable
     >>>> bind(X, 42)          # give it a value

Modified: pypy/dist/pypy/module/pypymagic/__init__.py
==============================================================================
--- pypy/dist/pypy/module/pypymagic/__init__.py	(original)
+++ pypy/dist/pypy/module/pypymagic/__init__.py	Sat Nov 11 19:57:56 2006
@@ -9,4 +9,3 @@
     interpleveldefs = {
         'pypy_repr'             : 'interp_magic.pypy_repr',
     }
-

Modified: pypy/dist/pypy/objspace/test/test_thunkobjspace.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_thunkobjspace.py	(original)
+++ pypy/dist/pypy/objspace/test/test_thunkobjspace.py	Sat Nov 11 19:57:56 2006
@@ -6,6 +6,7 @@
         cls.space = gettestobjspace('thunk')
 
     def test_simple(self):
+        from pypymagic import thunk, become
         computed = []
         def f():
             computed.append(True)
@@ -20,6 +21,7 @@
         assert computed == [True]
 
     def test_setitem(self):
+        from pypymagic import thunk, become
         computed = []
         def f(a):
             computed.append(True)
@@ -37,6 +39,7 @@
         assert d[7] == [43]
 
     def test_become(self):
+        from pypymagic import thunk, become
         x = []
         y = []
         assert x is not y
@@ -44,6 +47,7 @@
         assert x is y
 
     def test_id(self):
+        from pypymagic import thunk, become
         # these are the Smalltalk semantics of become().
         x = []; idx = id(x)
         y = []; idy = id(y)
@@ -52,6 +56,7 @@
         assert id(x) == id(y) == idy
 
     def test_double_become(self):
+        from pypymagic import thunk, become
         x = []
         y = []
         z = []
@@ -60,18 +65,21 @@
         assert x is y is z
 
     def test_thunk_forcing_while_forcing(self):
+        from pypymagic import thunk, become
         def f():
             return x+1
         x = thunk(f)
         raises(RuntimeError, 'x+1')
 
     def INPROGRESS_test_thunk_forcing_while_forcing_2(self):
+        from pypymagic import thunk, become
         def f():
             return x
         x = thunk(f)
         raises(RuntimeError, 'x+1')
 
     def test_is_thunk(self):
+        from pypymagic import thunk, become, is_thunk
         def f():
             pass
         assert is_thunk(thunk(f))

Modified: pypy/dist/pypy/objspace/thunk.py
==============================================================================
--- pypy/dist/pypy/objspace/thunk.py	(original)
+++ pypy/dist/pypy/objspace/thunk.py	Sat Nov 11 19:57:56 2006
@@ -1,6 +1,7 @@
 """Example usage:
 
     $ py.py -o thunk
+    >>> from pypymagic import thunk, become
     >>> def f():
     ...     print 'computing...'
     ...     return 6*7
@@ -152,10 +153,11 @@
     from pypy.objspace import std
     space = std.Space(*args, **kwds)
     patch_space_in_place(space, 'thunk', proxymaker)
-    space.setitem(space.builtin.w_dict, space.wrap('thunk'),
+    w_pypymagic = space.getbuiltinmodule("pypymagic")
+    space.setattr(w_pypymagic, space.wrap('thunk'),
                   space.wrap(app_thunk))
-    space.setitem(space.builtin.w_dict, space.wrap('is_thunk'),
+    space.setattr(w_pypymagic, space.wrap('is_thunk'),
                   space.wrap(app_is_thunk))
-    space.setitem(space.builtin.w_dict, space.wrap('become'),
+    space.setattr(w_pypymagic, space.wrap('become'),
                  space.wrap(app_become))
     return space



More information about the Pypy-commit mailing list