Iβm trying to create a copy for caching purposes, so I can load and make slight modifications to some traces without generating a new Figure which would take a lot of time in my Dash app.
Deepcopy used to be implemented for Figure, but it was removed somewhere along the way with recent updates. Regenerating from figure.to_dict() is unfortunately way too slow vs my prior use of deepcopy. A simple copy does not replicate the traces, instead only creating pointers.
Any suggestions? Creating copies of Traces seems to be the bottleneck here
With this optimization you would be able to write:
fig2 = go.Figure(fig1)
And it would perform the deep copy underneath and not re-trigger the validation of all of the properties in fig1, which I believe is whatβs slowing things down right now.
At this point, I think your only real option is to use raw dictionaries (rather that graph objects) for performance critical code.
Thanks @jmmease for creating this issue. Using raw dicts for now. The plotting function itself triggers validation though which may possibly slow down this method when passing in a dict.