Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Fast show()? (for cached plots for @interact)

Hello,

I need a fast (no noticeable delay) version of the following:

@interact
def _(a=(0,10)):
    time show(plot(lambda x:sin(a*x),plot_points=10000))

Time: CPU 2.65 s, Wall: 2.72 s


I can cache the plots, but showing them takes half a second:

@cached_function
def p(a):
    return plot(lambda x:sin(a*x),plot_points=10000)
for i in range(101):
    p(N(i/10))
@interact
def _(a=(0..100)):
    time p2=p(N(a/10))
    time show(p2)

Time: CPU 0.00 s, Wall: 0.00 s
Time: CPU 0.42 s, Wall: 0.43 s


Is there a faster way?

Thanks!