Does anyone know any tricks to speed up plot generation? Specifically, figure() takes around 25 seconds to run which is fine for automatically generated plots but could be kinda slow for plots that are generate on demand. I have three traces with 302,000 points each. the x axis is a datetime while the others are float32.
Here’s what the python profiler spits out for figure:
70876243 function calls (62706319 primitive calls) in 25.867 seconds
Ordered by: cumulative time
List reduced from 1855 to 50 due to restriction <50>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 25.867 25.867 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\_figure.py:14(__init__)
1 0.006 0.006 25.867 25.867 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:43(__init__)
8165169/311 11.796 0.000 25.673 0.083 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\copy.py:132(deepcopy)
345/311 0.001 0.000 25.672 0.083 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\copy.py:236(_deepcopy_dict)
27 0.725 0.027 25.670 0.951 {method '__deepcopy__' of 'numpy.ndarray' objects}
1 0.030 0.030 16.976 16.976 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\_plotly_utils\basevalidators.py:2242(validate_coerce)
2721459/2721444 3.796 0.000 11.562 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\copy.py:268(_reconstruct)
1 0.021 0.021 8.792 8.792 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:148(<listcomp>)
5 0.018 0.004 8.266 1.653 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:3414(to_plotly_json)
8164347 1.922 0.000 7.546 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\copy.py:273(<genexpr>)
16334987 2.211 0.000 2.211 0.000 {method 'get' of 'dict' objects}
2721834 1.339 0.000 1.926 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\copy.py:252(_keep_alive)
13609127 1.232 0.000 1.232 0.000 {built-in method builtins.id}
5443528 0.693 0.000 0.693 0.000 {built-in method builtins.getattr}
2721429 0.689 0.000 0.689 0.000 {method '__reduce_ex__' of 'datetime.datetime' objects}
2737444 0.404 0.000 0.404 0.000 {built-in method builtins.isinstance}
2728579 0.327 0.000 0.327 0.000 {method 'append' of 'list' objects}
2721495 0.311 0.000 0.311 0.000 {built-in method builtins.issubclass}
2721891 0.232 0.000 0.232 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\copy.py:190(_deepcopy_atomic)
3245/373 0.005 0.000 0.106 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:2745(__setitem__)
298/38 0.001 0.000 0.097 0.003 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\_plotly_utils\basevalidators.py:2090(validate_coerce)
297/60 0.002 0.000 0.097 0.002 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:3067(_set_compound_prop)
121/61 0.000 0.000 0.078 0.001 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:3697(__setitem__)
2 0.000 0.000 0.058 0.029 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\_layout.py:3758(__init__)
3651/2354 0.003 0.000 0.053 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:2811(__setattr__)
1 0.000 0.000 0.051 0.051 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:1340(_initialize_layout_template)
27/14 0.000 0.000 0.051 0.004 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:3723(__setattr__)
1 0.000 0.000 0.051 0.051 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\_layout.py:2350(template)
1 0.000 0.000 0.050 0.050 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\_plotly_utils\basevalidators.py:2344(validate_coerce)
1 0.000 0.000 0.050 0.050 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\layout\_template.py:188(__init__)
339/301 0.003 0.000 0.033 0.000 <frozen importlib._bootstrap>:978(_find_and_load)
4 0.001 0.000 0.028 0.007 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\_scattergl.py:1535(__init__)
525/487 0.001 0.000 0.024 0.000 <frozen importlib._bootstrap>:1009(_handle_fromlist)
42/2 0.000 0.000 0.023 0.011 <frozen importlib._bootstrap>:211(_call_with_frames_removed)
2 0.000 0.000 0.023 0.011 {built-in method builtins.__import__}
40/2 0.000 0.000 0.023 0.011 <frozen importlib._bootstrap>:948(_find_and_load_unlocked)
40/2 0.000 0.000 0.022 0.011 <frozen importlib._bootstrap>:663(_load_unlocked)
40/2 0.000 0.000 0.022 0.011 <frozen importlib._bootstrap_external>:722(exec_module)
40/2 0.000 0.000 0.021 0.011 {built-in method builtins.exec}
1 0.000 0.000 0.021 0.021 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\layout\template\_data.py:956(__init__)
1 0.000 0.000 0.019 0.019 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\validators\layout\template\data\__init__.py:1(<module>)
2868 0.004 0.000 0.017 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\basedatatypes.py:3003(_set_prop)
2 0.000 0.000 0.012 0.006 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\plotly\graph_objs\layout\_scene.py:1428(__init__)
299 0.001 0.000 0.012 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\site-packages\_plotly_utils\basevalidators.py:2064(data_class)
299 0.000 0.000 0.011 0.000 C:\Users\dgoodell\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py:109(import_module)
299 0.000 0.000 0.011 0.000 <frozen importlib._bootstrap>:994(_gcd_import)
40 0.000 0.000 0.010 0.000 <frozen importlib._bootstrap>:882(_find_spec)
126 0.000 0.000 0.010 0.000 <frozen importlib._bootstrap_external>:74(_path_stat)
126 0.010 0.000 0.010 0.000 {built-in method nt.stat}
40 0.000 0.000 0.010 0.000 <frozen importlib._bootstrap_external>:1272(find_spec)