"""
This file illustrates persistent functions, i.e., functions
whose values are cached to disk files.
"""

@func_persist
def bern(n):
    """
    Return the n-th Bernoulli number, caching the result to disk.
    """
    return bernoulli(n)


def bern2(n):
    """
    Return the n-th Bernoulli number, caching the result to disk.
    """
    return bernoulli(n)

@func_persist
def modsym(N, k):
    """
    Cached computation of modular symbols spaces
    with Hecke operators T_p for p < 100 computed.
    """
    M = ModularSymbols(N, k)
    M.basis()
    for p in primes(ZZ(100)):
        print p
        M.T(p).matrix()
    return M
