Skip to content

Commit 38ad84f

Browse files
committed
json_clean: Prevent making a set containing dict keys
This step eats up CPU cycles on each communication between ipykernel and the front-end.
1 parent c3797c3 commit 38ad84f

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

ipykernel/jsonutil.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@ def json_clean(obj):
123123
return [json_clean(x) for x in obj]
124124

125125
if isinstance(obj, dict):
126-
# First, validate that the dict won't lose data in conversion due to
127-
# key collisions after stringification. This can happen with keys like
128-
# True and 'true' or 1 and '1', which collide in JSON.
129-
nkeys = len(obj)
130-
nkeys_collapsed = len(set(map(str, obj)))
131-
if nkeys != nkeys_collapsed:
132-
raise ValueError('dict cannot be safely converted to JSON: '
133-
'key collision would lead to dropped values')
134126
# If all OK, proceed by making the new dict that will be json-safe
135127
out = {}
136128
for k, v in obj.items():

0 commit comments

Comments
 (0)