Skip to content

Commit 0ea1ba8

Browse files
committed
perf(utils): skip recursion into non-container list elements
In convert_to_base64, when iterating list/tuple elements, only recurse into dicts, lists, and tuples. Strings and numbers can never contain numpy arrays, so recursing into them wastes ~500K function calls on figures with large text arrays.
1 parent db79f58 commit 0ea1ba8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

_plotly_utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def _convert_to_base64(obj, np):
126126
_convert_to_base64(value, np)
127127
elif isinstance(obj, (list, tuple)):
128128
for value in obj:
129-
_convert_to_base64(value, np)
129+
if isinstance(value, (dict, list, tuple)):
130+
_convert_to_base64(value, np)
130131

131132

132133
def cumsum(x):

0 commit comments

Comments
 (0)