Home - Summaries: (main) : (py3.11) : (py3.12) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

pypy/objspace/std/test/test_methodcache.py::AppTestMethodCaching::()::test_many_names

self = <pypy.interpreter.typedef.W_ObjectObjectUserDictWeakrefable object at 0x00007fef9e198410>

    def test_many_names(self):
>           @self.retry
            def run():
                import __pypy__

[/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/objspace/std/test/test_methodcache.py:72]:2: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

run = <Function run>

>   ???

?:10: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    @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
    
            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

[/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/objspace/std/test/test_methodcache.py:72]:44: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    @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
    
            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
E               (application-level) AssertionError

[/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/objspace/std/test/test_methodcache.py:72]:37: AssertionError
builder: own-macos-x86-64 build #1335+
test: pypy/objspace/std/test/test_methodcache.py::AppTestMethodCaching::()::test_many_names