I have the code below and find that bokeh is very slow to update the graphs, is there something I am doing wrong that would allow faster updates of the graphs?

import numpy as np

from numpy import pi

import bokeh

from bokeh.client import push_session

from bokeh.driving import cosine

from bokeh.plotting import Figure, curdoc

from bokeh.models.widgets import Select

from bokeh.models import ColumnDataSource, HBox, VBoxForm

from bokeh.models.widgets import Slider, TextInput, Toggle

import re

x = [0]

y = [0]

p = Figure()

#r1 = p.line([0, 4*pi], [-1, 1], color=“firebrick”)

r2 = p.line(x, y, color=“navy”, line_width=4)

p2=Figure()

r1=p2.line(x, y, color=“red”, line_width=4)

p3=Figure()

r3=p3.line(x, y, color=“red”, line_width=4)

r3a=p3.line(x, y, color=“blue”, line_width=2)

p2.x_range=p.x_range

p3.x_range=p.x_range

def ClearGraph():

r2.data_source.data[“y”] =

r2.data_source.data[“x”] =

r1.data_source.data[“y”] =

r1.data_source.data[“x”] =

r3.data_source.data[“y”] =

r3a.data_source.data[“y”] =

r3.data_source.data[“x”] =

r3a.data_source.data[“x”] =

p2.x_range=p.x_range

p3.x_range=p.x_range

def updateGraph():

N=200000;

p.title=""

print “Data Loaded”

x1=range(N)

y1=np.random.rand(N)

c1=np.random.rand(N)

t1=np.random.rand(N)

p1=np.random.rand(N)

print “Transform done”

r2.data_source.data[“y”] = c1

r2.data_source.data[“x”] = x1

print “graph1 done”

r1.data_source.data[“y”] = y1

r1.data_source.data[“x”] = x1

print “graph2 done”

r3.data_source.data[“y”] = t1

r3a.data_source.data[“y”] = p1

r3.data_source.data[“x”] = x1

r3a.data_source.data[“x”] = x1

print “graph3 done”

# p2.x_range=p.x_range

# p3.x_range=p.x_range

p.title=“Done”

print len(x1)

def button_click(something):

#button.disabled=True

updateGraph()

#button.disabled=False

#print “button update”

button = Toggle(label=“Update Graph”, type=“success”)

button.on_click(button_click)

inputs = VBoxForm(children=[button])

x=VBoxForm(children=[p,p2,p3])

curdoc().add_root(HBox(children=[inputs,x], width=1000))

session = push_session(curdoc())

# @cosine(w=0.03)

# def update(step):

# r2.data_source.data[“y”] = y * step

# r2.glyph.line_alpha = 1 - 0.8 * abs(step)

#curdoc().add_periodic_callback(updateGraph, 30000)

session.show() # open the document in a browser

session.loop_until_closed() # run forever