Bad performance after upgrading plotly from version 2 to 3

I am testing the performance by drawing 1000 reticles all from (0,0,0) as following code:

print('plot version', plotly.__version__)
t1 = time.time()
for i in range(5, 15):
  for j in range(5, 15):
    for k in range(5, 15):
      graph_objs.Scatter3d(
          x=[0, i], y=[0, j], z=[0, k], mode='lines', showlegend=False)
print('delta t for 1000 points', time.time() - t1)`

Then I tested version 2 and 3 got following output:

plot version 2.0.13
delta t for 1000 points 0.0404090881348

plot version 3.4.2
delta t for 1000 points 2.66915583611

Itโ€™s about 7X slower. Is there something I need to set specifically for new version to get back the same performance?

@maoxm.g, there was a similar issue posted on plotly.pyโ€™s github page a while back. This comment provides some advice on how you can speed things up.

Basically, you can replace graph_objs.Scatter3d(...) with dict(type='scatter3d', x=[0, i], y=[0, j], z=[0, k], mode='lines', showlegend=False) and then pass validate=False into iplot to prevent any time consuming validation. Consult the reference page if you need to figure out how to translate a graph_obj into the correct type (e.g https://plot.ly/javascript/reference/#scatter3d)

1 Like

Thanks a lot for the link. Thatโ€™s the exact issue I found before in github page and I lost it.