diff --git a/FIAT/reference_element.py b/FIAT/reference_element.py index 0dcb5825e..a34b444ee 100644 --- a/FIAT/reference_element.py +++ b/FIAT/reference_element.py @@ -38,6 +38,7 @@ QUADRILATERAL = 11 HEXAHEDRON = 111 TENSORPRODUCT = 99 +_family_cache = {} def multiindex_equal(d, isum, imin=0): @@ -77,7 +78,11 @@ def make_lattice(verts, n, interior=0, family="equi"): and interior = 0, this function will return the vertices and midpoint, but with interior = 1, it will only return the midpoint.""" - family = _decode_family(family) + key = family + try: + family = _family_cache[key] + except KeyError: + family = _family_cache.setdefault(key, _decode_family(family)) D = len(verts) X = numpy.array(verts) get_point = lambda alpha: tuple(numpy.dot(_recursive(D - 1, n, alpha, family), X))