[pypy-commit] pypy py3k: Correct indentation to be a multiple of four.
mjacob
noreply at buildbot.pypy.org
Wed Jun 3 23:30:57 CEST 2015
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3k
Changeset: r77843:d4d74edf6a05
Date: 2015-06-03 19:38 +0200
http://bitbucket.org/pypy/pypy/changeset/d4d74edf6a05/
Log: Correct indentation to be a multiple of four.
diff --git a/pypy/objspace/std/test/test_methodcache.py b/pypy/objspace/std/test/test_methodcache.py
--- a/pypy/objspace/std/test/test_methodcache.py
+++ b/pypy/objspace/std/test/test_methodcache.py
@@ -48,113 +48,113 @@
def test_change_methods(self):
# this test fails because of the following line in typeobject.py:427
# if cached_name is name:
-
+
# in py3k, identifiers are stored in W_UnicodeObject and unwrapped by
# calling space.str_w, which .encode('ascii') the string, thus
# creating new strings all the time. The problem should be solved when
# we implement proper unicode identifiers in py3k
@self.retry
def run():
- import __pypy__
- class A(object):
- def f(self):
- return 42
- l = [A()] * 10
- __pypy__.reset_method_cache_counter()
- for i, a in enumerate(l):
- assert a.f() == 42 + i
- A.f = eval("lambda self: %s" % (42 + i + 1, ))
- cache_counter = __pypy__.method_cache_counter("f")
- #
- # a bit of explanation about what's going on. (1) is the line "a.f()"
- # and (2) is "A.f = ...".
- #
- # at line (1) we do the lookup on type(a).f
- #
- # at line (2) we do a setattr on A. However, descr_setattr does also a
- # lookup of type(A).f i.e. type.f, to check if by chance 'f' is a data
- # descriptor.
- #
- # At the first iteration:
- # (1) is a miss because it's the first lookup of A.f. The result is cached
- #
- # (2) is a miss because it is the first lookup of type.f. The
- # (non-existant) result is cached. The version of A changes, and 'f'
- # is changed to be a cell object, so that subsequest assignments won't
- # change the version of A
- #
- # At the second iteration:
- # (1) is a miss because the version of A changed just before
- # (2) is a hit, because type.f is cached. The version of A no longer changes
- #
- # At the third and subsequent iterations:
- # (1) is a hit, because the version of A did not change
- # (2) is a hit, see above
- assert cache_counter == (17, 3)
+ import __pypy__
+ class A(object):
+ def f(self):
+ return 42
+ l = [A()] * 10
+ __pypy__.reset_method_cache_counter()
+ for i, a in enumerate(l):
+ assert a.f() == 42 + i
+ A.f = eval("lambda self: %s" % (42 + i + 1, ))
+ cache_counter = __pypy__.method_cache_counter("f")
+ #
+ # a bit of explanation about what's going on. (1) is the line "a.f()"
+ # and (2) is "A.f = ...".
+ #
+ # at line (1) we do the lookup on type(a).f
+ #
+ # at line (2) we do a setattr on A. However, descr_setattr does also a
+ # lookup of type(A).f i.e. type.f, to check if by chance 'f' is a data
+ # descriptor.
+ #
+ # At the first iteration:
+ # (1) is a miss because it's the first lookup of A.f. The result is cached
+ #
+ # (2) is a miss because it is the first lookup of type.f. The
+ # (non-existant) result is cached. The version of A changes, and 'f'
+ # is changed to be a cell object, so that subsequest assignments won't
+ # change the version of A
+ #
+ # At the second iteration:
+ # (1) is a miss because the version of A changed just before
+ # (2) is a hit, because type.f is cached. The version of A no longer changes
+ #
+ # At the third and subsequent iterations:
+ # (1) is a hit, because the version of A did not change
+ # (2) is a hit, see above
+ assert cache_counter == (17, 3)
def test_subclasses(self):
@self.retry
def run():
- import __pypy__
- class A(object):
- def f(self):
- return 42
- class B(object):
- def f(self):
- return 43
- class C(A):
- pass
- l = [A(), B(), C()] * 10
- __pypy__.reset_method_cache_counter()
- for i, a in enumerate(l):
- assert a.f() == 42 + (i % 3 == 1)
- cache_counter = __pypy__.method_cache_counter("f")
- assert cache_counter[0] >= 15
- assert cache_counter[1] >= 3 # should be (27, 3)
- assert sum(cache_counter) == 30
-
+ import __pypy__
+ class A(object):
+ def f(self):
+ return 42
+ class B(object):
+ def f(self):
+ return 43
+ class C(A):
+ pass
+ l = [A(), B(), C()] * 10
+ __pypy__.reset_method_cache_counter()
+ for i, a in enumerate(l):
+ assert a.f() == 42 + (i % 3 == 1)
+ cache_counter = __pypy__.method_cache_counter("f")
+ assert cache_counter[0] >= 15
+ assert cache_counter[1] >= 3 # should be (27, 3)
+ assert sum(cache_counter) == 30
+
def test_many_names(self):
@self.retry
def run():
import __pypy__
laste = None
for j in range(20):
- class A(object):
- def f(self):
- return 42
- class B(object):
- def f(self):
- return 43
- class C(A):
- pass
- l = [A(), B(), C()] * 10
- __pypy__.reset_method_cache_counter()
- for i, a in enumerate(l):
- assert a.f() == 42 + (i % 3 == 1)
- cache_counter = __pypy__.method_cache_counter("f")
- assert cache_counter[0] >= 15
- assert cache_counter[1] >= 3 # should be (27, 3)
- assert sum(cache_counter) == 30
+ class A(object):
+ def f(self):
+ return 42
+ class B(object):
+ def f(self):
+ return 43
+ class C(A):
+ pass
+ l = [A(), B(), C()] * 10
+ __pypy__.reset_method_cache_counter()
+ for i, a in enumerate(l):
+ assert a.f() == 42 + (i % 3 == 1)
+ cache_counter = __pypy__.method_cache_counter("f")
+ assert cache_counter[0] >= 15
+ assert cache_counter[1] >= 3 # should be (27, 3)
+ assert sum(cache_counter) == 30
- a = A()
- names = [name for name in A.__dict__.keys()
- if not name.startswith('_')]
- names.sort()
- names_repeated = names * 10
- result = []
- __pypy__.reset_method_cache_counter()
- for name in names_repeated:
- result.append(getattr(a, name))
- append_counter = __pypy__.method_cache_counter("append")
- names_counters = [__pypy__.method_cache_counter(name)
- for name in names]
- try:
- assert append_counter[0] >= 10 * len(names) - 1
- for name, count in zip(names, names_counters):
- assert count == (9, 1), str((name, count))
- break
- except AssertionError as e:
- laste = e
+ a = A()
+ names = [name for name in A.__dict__.keys()
+ if not name.startswith('_')]
+ names.sort()
+ names_repeated = names * 10
+ result = []
+ __pypy__.reset_method_cache_counter()
+ for name in names_repeated:
+ result.append(getattr(a, name))
+ append_counter = __pypy__.method_cache_counter("append")
+ names_counters = [__pypy__.method_cache_counter(name)
+ for name in names]
+ try:
+ assert append_counter[0] >= 10 * len(names) - 1
+ for name, count in zip(names, names_counters):
+ assert count == (9, 1), str((name, count))
+ break
+ except AssertionError as e:
+ laste = e
else:
raise laste
More information about the pypy-commit
mailing list