[pypy-commit] pypy kill-ootype: hg merge default

rlamy noreply at buildbot.pypy.org
Sun Jul 7 14:22:21 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-ootype
Changeset: r65249:85e691b55007
Date: 2013-07-07 03:56 +0200
http://bitbucket.org/pypy/pypy/changeset/85e691b55007/

Log:	hg merge default

diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -907,7 +907,7 @@
 runs at application level. If you need to use modules
 you have to import them within the test function.
 
-Another possibility to pass in data into the AppTest is to use
+Data can be passed into the AppTest using 
 the ``setup_class`` method of the AppTest. All wrapped objects that are
 attached to the class there and start with ``w_`` can be accessed
 via self (but without the ``w_``) in the actual test method. An example::
@@ -922,6 +922,46 @@
 
 .. _`run the tests as usual`:
 
+Another possibility is to use cls.space.appexec, for example::
+
+    class AppTestSomething(object):
+        def setup_class(cls):
+            arg = 2
+            cls.w_result = cls.space.appexec([cls.space.wrap(arg)], """(arg):
+                return arg ** 6
+                """)
+
+        def test_power(self):
+            assert self.result == 2 ** 6
+
+which executes the code string function with the given arguments at app level.
+Note the use of ``w_result`` in ``setup_class`` but self.result in the test 
+Here is how to define an app level class  in ``setup_class`` that can be used
+in subsequent tests::
+
+    class AppTestSet(object):
+        def setup_class(cls):
+            w_fakeint = cls.space.appexec([], """():
+                class FakeInt(object):
+                    def __init__(self, value):
+                        self.value = value
+                    def __hash__(self):
+                        return hash(self.value)
+
+                    def __eq__(self, other):
+                        if other == self.value:
+                            return True
+                        return False
+                return FakeInt
+                """)
+            cls.w_FakeInt = w_fakeint
+
+        def test_fakeint(self):
+            f1 = self.FakeInt(4)
+            assert f1 == 4
+            assert hash(f1) == hash(4)
+
+
 Command line tool test_all
 --------------------------
 
diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -96,8 +96,21 @@
 Does PyPy have a GIL?  Why?
 -------------------------------------------------
 
-Yes, PyPy has a GIL.  Removing the GIL is very hard.  The first problem
-is that our garbage collectors are not re-entrant.
+Yes, PyPy has a GIL.  Removing the GIL is very hard.  The problems are
+essentially the same as with CPython (including the fact that our
+garbage collectors are not thread-safe so far).  Fixing it is possible,
+as shown by Jython and IronPython, but difficult.  It would require
+adapting the whole source code of PyPy, including subtle decisions about
+whether some effects are ok or not for the user (i.e. the Python
+programmer).
+
+Instead, since 2012, there is work going on on a still very experimental
+Software Transactional Memory (STM) version of PyPy.  This should give
+an alternative PyPy which internally has no GIL, while at the same time
+continuing to give the Python programmer the complete illusion of having
+one.  It would in fact push forward *more* GIL-ish behavior, like
+declaring that some sections of the code should run without releasing
+the GIL in the middle (these are called *atomic sections* in STM).
 
 ------------------------------------------
 How do I write extension modules for PyPy?
@@ -322,8 +335,32 @@
 Yes, it is possible with enough effort to compile small self-contained
 pieces of RPython code doing a few performance-sensitive things.  But
 this case is not interesting for us.  If you needed to rewrite the code
-in RPython, you could as well have rewritten it in C for example.  The
-latter is a much more supported, much more documented language `:-)`
+in RPython, you could as well have rewritten it in C or C++ or Java for
+example.  These are much more supported, much more documented languages
+`:-)`
+
+  *The above paragraphs are not the whole truth.  It* is *true that there
+  are cases where writing a program as RPython gives you substantially
+  better speed than running it on top of PyPy.  However, the attitude of
+  the core group of people behind PyPy is to answer: "then report it as a
+  performance bug against PyPy!".*
+
+  *Here is a more diluted way to put it.  The "No, don't!" above is a
+  general warning we give to new people.  They are likely to need a lot
+  of help from* some *source, because RPython is not so simple nor
+  extensively documented; but at the same time, we, the pypy core group
+  of people, are not willing to invest time in supporting 3rd-party
+  projects that do very different things than interpreters for dynamic
+  languages --- just because we have other interests and there are only
+  so many hours a day.  So as a summary I believe it is only fair to
+  attempt to point newcomers at existing alternatives, which are more
+  mainstream and where they will get help from many people.*
+
+  *If anybody seriously wants to promote RPython anyway, he is welcome
+  to: we won't actively resist such a plan.  This is open source, which
+  means that anybody is free to promote and develop anything; but it
+  also means that you must let us choose* not *to go into that direction
+  ourselves.*
 
 ---------------------------------------------------
 Which backends are there for the RPython toolchain?
diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -131,18 +131,19 @@
     def has_id(self, id):
         return id in self.ids
 
-    def _ops_for_chunk(self, chunk, include_debug_merge_points):
+    def _ops_for_chunk(self, chunk, include_guard_not_invalidated):
         for op in chunk.operations:
-            if op.name != 'debug_merge_point' or include_debug_merge_points:
+            if op.name != 'debug_merge_point' and \
+                (op.name != 'guard_not_invalidated' or include_guard_not_invalidated):
                 yield op
 
-    def _allops(self, include_debug_merge_points=False, opcode=None):
+    def _allops(self, opcode=None, include_guard_not_invalidated=True):
         opcode_name = opcode
         for chunk in self.flatten_chunks():
             opcode = chunk.getopcode()
             if opcode_name is None or \
                    (opcode and opcode.__class__.__name__ == opcode_name):
-                for op in self._ops_for_chunk(chunk, include_debug_merge_points):
+                for op in self._ops_for_chunk(chunk, include_guard_not_invalidated):
                     yield op
             else:
                for op in  chunk.operations:
@@ -162,15 +163,15 @@
     def print_ops(self, *args, **kwds):
         print self.format_ops(*args, **kwds)
 
-    def _ops_by_id(self, id, include_debug_merge_points=False, opcode=None):
+    def _ops_by_id(self, id, include_guard_not_invalidated=True, opcode=None):
         opcode_name = opcode
         target_opcodes = self.ids[id]
-        loop_ops = self.allops(include_debug_merge_points, opcode)
+        loop_ops = self.allops(opcode)
         for chunk in self.flatten_chunks():
             opcode = chunk.getopcode()
             if opcode in target_opcodes and (opcode_name is None or
                                              opcode.__class__.__name__ == opcode_name):
-                for op in self._ops_for_chunk(chunk, include_debug_merge_points):
+                for op in self._ops_for_chunk(chunk, include_guard_not_invalidated):
                     if op in loop_ops:
                         yield op
 
diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -223,5 +223,5 @@
         log = self.run(main, [1000])
         assert log.result == main(1000)
         loop, = log.loops_by_filename(self.filepath)
-        ops = loop.ops_by_id('getitem')
+        ops = loop.ops_by_id('getitem', include_guard_not_invalidated=False)
         assert log.opnames(ops) == []
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -80,7 +80,7 @@
             i23 = strgetitem(p10, i19)
             p25 = newstr(1)
             strsetitem(p25, 0, i23)
-            p93 = call(ConstClass(fromstr), p25, 16, ConstPtr(ptr70), descr=<Callr . rir EF=3>)
+            p93 = call(ConstClass(fromstr), p25, 16, descr=<Callr . ri EF=3>)
             guard_no_exception(descr=...)
             i94 = call(ConstClass(rbigint.toint), p93, descr=<Calli . r EF=3>)
             guard_no_exception(descr=...)
diff --git a/rpython/jit/backend/arm/test/conftest.py b/rpython/jit/backend/arm/test/conftest.py
--- a/rpython/jit/backend/arm/test/conftest.py
+++ b/rpython/jit/backend/arm/test/conftest.py
@@ -16,7 +16,5 @@
                     dest="run_translation_tests",
                     help="run tests that translate code")
 
-def pytest_collect_directory(path, parent):
-    if not cpu.startswith('arm'):
-        py.test.skip("ARM(v7) tests skipped: cpu is %r" % (cpu,))
-pytest_collect_file = pytest_collect_directory
+def pytest_ignore_collect(path, config):
+    return not cpu.startswith('arm')


More information about the pypy-commit mailing list