def memoize(ctx, f):
        f_cache = {}
        def f_cached(*args, **kwargs):
            if kwargs:
                key = args, tuple(kwargs.items())
            else:
                key = args
            prec = ctx.prec
            if key in f_cache:
                cprec, cvalue = f_cache[key]
                if cprec >= prec:
                    return +cvalue
            value = f(*args, **kwargs)
            f_cache[key] = (prec, value)
            return value
        f_cached.__name__ = f.__name__
        f_cached.__doc__ = f.__doc__
        return f_cached
Test if logging can be disabled.
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/ctx_base.py/StandardBaseContext.memoize--crossover with--dataset/ETHPy150Open zlorf/django-synchro/synchro/tests.py/AdvancedSynchroTests.test_disabling