[issue29540] Add compact=True flag to json.dump/dumps

2017-03-14 Thread Ben Hoyt
Ben Hoyt added the comment: Agreed. Seems much the same as other argument constants, like pickle.HIGHEST_PROTOCOL for the "protocol" argument. These are not changing the API, just adding a helper constant to avoid the magic values. -Ben On Tue, Mar 14, 2017 at 12:24 PM, Brett Cannon

[issue29540] Add compact=True flag to json.dump/dumps

2017-03-14 Thread Brett Cannon
Brett Cannon added the comment: I agree with David that I don't see how adding a constant to the module is really a complication of an API. -- ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-03-14 Thread R. David Murray
R. David Murray added the comment: I don't see how adding a constant increases the complexity of the API. -- ___ Python tracker ___

[issue29540] Add compact=True flag to json.dump/dumps

2017-03-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Serhiy] > Personally I dislike any complication of json API. > Likely it is already the most complicated API in the stdlib. [Bob Ippolito] > the interface here is already a bit too complex > and the benefit is pretty minimal I concur with those

[issue29540] Add compact=True flag to json.dump/dumps

2017-03-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I expressed my opinion, but I am ready to change it if this proposal meets the support of other core developers after discussion on the mailing list. -- ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-03-13 Thread Brett Cannon
Brett Cannon added the comment: So new options sounds like a no-go, but what about the COMPACT attribute on the json module as per https://github.com/python/cpython/pull/72? -- ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-19 Thread Bob Ippolito
Bob Ippolito added the comment: I would recommend a moratorium on new options until we have a plan to make the usage of the JSON APIs simpler overall. It's accumulated too many options over time. The real trouble is figuring out how to do this in a backwards compatible way that does not

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-19 Thread Andrew Nester
Andrew Nester added the comment: Adding new argument sucs as format= or compact= will make API more complicated. In addition it's not easy and has obvious how to handle situations wheb we have both separatots= and format= arguments set. -- ___

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Since core developers have different opinions about this issue, it should be discussed on the Python-Dev maillist until one side convince the other side or BDFL make his decision. Personally I dislike any complication of json API. Likely it is already the

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-17 Thread Ben Hoyt
Ben Hoyt added the comment: I agree with the confusion (PR proposes separators=COMPACT, issue compact=True). I like the concept but not either of the APIs proposed. I *much* more often want to get pretty output -- if I had a dime for every time I've written "json.dumps(obj, sort_keys=True,

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: Everyone can chime in with their thoughts, but Bob gets to make the decision on this one. -- ___ Python tracker ___

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-14 Thread Brett Cannon
Brett Cannon added the comment: I'm a little confused as the PR proposes a COMPACT constant for the module but the issue proposes a new compact argument. Which are we actively considering? -- ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-14 Thread STINNER Victor
STINNER Victor added the comment: "Add compact=True flag to json.dump/dumps" Oh, fun, I implemented exactly this option in my perf project. Extract: def dump(data, fp, compact): kw = {} if compact: kw['separators'] = (',', ':') else:

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-14 Thread Berker Peksag
Berker Peksag added the comment: I'm +1 on the idea. Currently, a user needs to find this information in a wall of text: "To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace." It's easy to miss the lack of trailing space in (',', ':'). Perhaps

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-14 Thread Alex Gordon
Alex Gordon added the comment: The point is that, as a principle of good API design, the json module should not generate malformed JSON unless the user very explicitly asks for their JSON to be corrupted. Python stands alone in having a JSON serializer that can produce strings such as

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-14 Thread Bob Ippolito
Bob Ippolito added the comment: I agree, in isolation it's a fine proposal, but the interface here is already a bit too complex and the benefit is pretty minimal. When the size really does matter, you can take care to set it correctly once and be done with it. --

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Serhiy and think this API change would be a net increase in complexity. FWIW, network transmission size issues can already be handled more effectively "Accept-Encoding: gzip, deflate". Bob, do you have any thoughts? -- assignee: ->

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm -1. This adds the maintenance and learning burden and doesn't make the user code more clear. The reader needs to search what json.COMPACT means. -- nosy: +serhiy.storchaka ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-13 Thread Andrew Nester
Andrew Nester added the comment: I've just added PR implementing alternative version provided by R. David Murray as more simple and straight-forward one. -- nosy: +andrewnester pull_requests: +53 ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-13 Thread R. David Murray
R. David Murray added the comment: An alternative would be to define a COMPACT constant in the json module equal to (',', ':'). -- nosy: +r.david.murray ___ Python tracker

[issue29540] Add compact=True flag to json.dump/dumps

2017-02-12 Thread Alex Gordon
New submission from Alex Gordon: Broadly speaking, there are three main output styles for json.dump/dumps: 1. Default: json.dumps(obj) 2. Compact: json.dumps(obj, separators=(',', ':')) 3. Pretty-printing: json.dumps(obj, sort_keys=True, indent=4) The 'compact' style is the densest, suitable