Generate functions inside a function from string

Well, I am working with SymPy. I would like to build a symbolic matrix and then numerically calculate it. However I found SymPy cannot do the calculation fast enough, e.g.

using SymPy

@vars x

expr=integrate(sin(x))
f=eval(parse("x->$(repr(expr))"))
g=lambdify(expr,[x])

@time subs(expr,x=>1.0)
@time f(1.0)
@time g(1.0)

# timing:
# 0.000365 seconds (80 allocations: 2.453 KiB)
# 0.000003 seconds (5 allocations: 176 bytes)
# 0.000016 seconds (9 allocations: 240 bytes)

I found eval is the fastest. As I have to diagonalize a rather large matrix many times (e.g. ten thousand of 400*400 matrices), I want to make the performance better.

Besides, I thought building something from string should not be a very uncommon thing…