0

I need to store big amount of math formulas in json and then evaluate them in python with various arguments. And do it fast Example of formula: 1015995338000000 - (1.180266595461174895340000000E+28 / (11616850504302 + input * 12.884))

evaluation code:

input = Symbol("input")
parsed = parse_expr(formula, local_dict={"input": input})
results = []
for input_value in values:
  results.append(Decimal(str(parsed.subs(input, input_value))))

Now I use sympy's parse_expr, but it too slow and also have overhead with casting Float to Decimal.

I's there more optimal way to eval expressions with sympy? Or faster library in python?

0 Answers0