You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Encode set, frozenset, bytearray, and iterators as json arrays #75338
Currently json.dump, json.dumps, and json.JSONEncoder do not support writing iterator objects. Users can choose to pass the iterator to a tuple and write that as a json array, but this is wasteful if the iterator is large, requiring a large amount of memory to be temporarily allocated for the tuple prior to json encoding.
The json module also does not support writing sets, frozensets, or bytearrays.
Activity
onealj commentedon Aug 9, 2017
Currently json.dump, json.dumps, and json.JSONEncoder do not support writing iterator objects. Users can choose to pass the iterator to a tuple and write that as a json array, but this is wasteful if the iterator is large, requiring a large amount of memory to be temporarily allocated for the tuple prior to json encoding.
The json module also does not support writing sets, frozensets, or bytearrays.
salty-horse commentedon Apr 26, 2018
If sets are to be supported, then so should dictionary views.
Please also consider the range type.
rhettinger commentedon Apr 26, 2018
There is some virtue to the current design. Having a user explicitly cast to a list will avoid unintentional conversions.
methane commentedon Apr 8, 2019
I concur with Raymond.
If you really need this feature, please discuss on python-dev ML.