1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
"""Cache some things."""
from functools import lru_cache
from sympy import sympify as _orig_sympify, simplify as _orig_simplify, count_ops
from public import public
@public
@lru_cache(maxsize=256, typed=True)
def sympify(
a, locals=None, convert_xor=True, strict=False, rational=False, evaluate=None
):
return _orig_sympify(a, locals, convert_xor, strict, rational, evaluate)
@public
@lru_cache(maxsize=256, typed=True)
def simplify(
expr,
ratio=1.7,
measure=count_ops,
rational=False,
inverse=False,
doit=True,
**kwargs,
):
return _orig_simplify(
expr,
ratio=ratio,
measure=measure,
rational=rational,
inverse=inverse,
doit=doit,
**kwargs,
)
|