This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Encode set, frozenset, bytearray, and iterators as json arrays
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: bob.ippolito Nosy List: bob.ippolito, javenoneal, methane, rhettinger, salty-horse, sedrubal
Priority: normal Keywords:

Created on 2017-08-09 09:23 by javenoneal, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3034 closed javenoneal, 2017-08-09 09:23
Messages (4)
msg299981 - (view) Author: Javen O'Neal (javenoneal) * Date: 2017-08-09 09:23
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.
msg315782 - (view) Author: Ori Avtalion (salty-horse) * Date: 2018-04-26 07:48
If sets are to be supported, then so should dictionary views.

Please also consider the range type.
msg315789 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-26 12:21
There is some virtue to the current design.  Having a user explicitly cast to a list will avoid unintentional conversions.
msg339597 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-08 07:52
I concur with Raymond.
If you really need this feature, please discuss on python-dev ML.
History
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75338
2021-10-07 08:11:02sedrubalsetnosy: + sedrubal
2019-04-08 07:52:33methanesetstatus: open -> closed

nosy: + methane
messages: + msg339597

resolution: rejected
stage: resolved
2018-04-26 12:21:11rhettingersetnosy: + rhettinger
messages: + msg315789
2018-04-26 07:48:09salty-horsesetnosy: + salty-horse
messages: + msg315782
2017-08-09 19:15:47rhettingersetassignee: bob.ippolito

nosy: + bob.ippolito
2017-08-09 09:23:16javenonealcreate