[pypy-commit] pypy default: a neat debugging feature
fijal
noreply at buildbot.pypy.org
Tue Dec 27 14:18:41 CET 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r50902:a8481f7a34ed
Date: 2011-12-27 15:18 +0200
http://bitbucket.org/pypy/pypy/changeset/a8481f7a34ed/
Log: a neat debugging feature
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -4,6 +4,7 @@
class PyPyModule(MixedModule):
interpleveldefs = {
'debug_repr': 'interp_extras.debug_repr',
+ 'remove_invalidates': 'interp_extras.remove_invalidates',
}
appleveldefs = {}
diff --git a/pypy/module/micronumpy/interp_extras.py b/pypy/module/micronumpy/interp_extras.py
--- a/pypy/module/micronumpy/interp_extras.py
+++ b/pypy/module/micronumpy/interp_extras.py
@@ -5,3 +5,11 @@
@unwrap_spec(array=BaseArray)
def debug_repr(space, array):
return space.wrap(array.find_sig().debug_repr())
+
+ at unwrap_spec(array=BaseArray)
+def remove_invalidates(space, array):
+ """ Array modification will no longer invalidate any of it's
+ potential children. Use only for performance debugging
+ """
+ del array.invalidates[:]
+ return space.w_None
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -898,6 +898,15 @@
b[0] = 3
assert debug_repr(b) == 'Array'
+ def test_remove_invalidates(self):
+ from numpypy import array
+ from numpypy.pypy import remove_invalidates
+ a = array([1, 2, 3])
+ b = a + a
+ remove_invalidates(a)
+ a[0] = 14
+ assert b[0] == 28
+
def test_virtual_views(self):
from numpypy import arange
a = arange(15)
More information about the pypy-commit
mailing list