Skip to content

Commit cdfe7bd

Browse files
committed
Some more performance improvements
1 parent afe9065 commit cdfe7bd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/inspectorscripts.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ def _jupyterlab_variableinspector_getshapeof(x):
101101
def _jupyterlab_variableinspector_getcontentof(x):
102102
# returns content in a friendly way for python variables
103103
# pandas and numpy
104-
if __pd and isinstance(x, __pd.DataFrame):
104+
if isinstance(x, (bool, str, int, float, type(None))):
105+
content = str(x)
106+
elif isinstance(x, (list, tuple)):
107+
if len(x) < 10:
108+
content = str(x)
109+
else:
110+
content = f"[{x[0]}, {x[1]}, {x[2]}, ..., {x[-1]}]"
111+
elif __pd and isinstance(x, __pd.DataFrame):
105112
colnames = ', '.join(x.columns.map(str))
106113
content = "Columns: %s" % colnames
107114
elif __pd and isinstance(x, __pd.Series):
@@ -152,7 +159,7 @@ def _jupyterlab_variableinspector_dict_list():
152159
def keep_cond(v):
153160
try:
154161
obj = eval(v)
155-
if isinstance(obj, (bool, str, list, int, float, type(None))):
162+
if isinstance(obj, (bool, str, list, tuple, int, float, type(None))):
156163
return True
157164
if __tf and isinstance(obj, __tf.Variable):
158165
return True

0 commit comments

Comments
 (0)