[issue30670] pprint for dict in sorted order or insert order?

2019-03-22 Thread GUIHOT Xavier


Change by GUIHOT Xavier :


--
pull_requests: +12455

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-03-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for the contribution.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-03-22 Thread Raymond Hettinger

Raymond Hettinger  added the comment:


New changeset 96831c7fcf888af187bbae8254608cccb4d6a03c by Raymond Hettinger 
(Rémi Lapeyre) in branch 'master':
bpo-30670: Add pp function to the pprint module (GH-11769)
https://github.com/python/cpython/commit/96831c7fcf888af187bbae8254608cccb4d6a03c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

I agree with Karthikeyan, I would expect sort=True to sort all collections, 
including tuples and lists for example.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

> pprint only sorts dicts currently so sort_dicts is better than sort that 
> sounds more general. 

Yes. Because pprint just sort dicts, I think that is better rename the 
parameter like just sort. But was an opinion, that does not affect to the 
behavior. 

> sort_dicts=True is the current behavior so I guess this is backwards 
> compatible way to do this change.

I understand it. I was confuse.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

pprint only sorts dicts currently so sort_dicts is better than sort that sounds 
more general. sort_dicts=True is the current behavior so I guess this is 
backwards compatible way to do this change.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi!

>def pprint(data, *, sort_dicts=True):
>...

>def pp(data, *args, **kwds):
>pprint(data, *args, sort_dicts=False, **kwds)

We could use the parameters `sort=`? IMHO is better a short parameters name.

If we assign by default sort_dicts=True, that would have some error on 
unittest, isn't?

--
nosy: +eamanu

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
keywords: +patch, patch
pull_requests: +11732, 11733
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
keywords: +patch, patch, patch
pull_requests: +11732, 11733, 11734
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-06 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
keywords: +patch
pull_requests: +11732
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-04 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
stage: resolved -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-04 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Consider adding a flag to switch between sorted order and insertion order 
(defaulting to the current behavior).  For convenience, add a short-cut 
function to call pprint() with the flag set to False.

def pprint(data, *, sort_dicts=True):
...

def pp(data, *args, **kwds):
pprint(data, *args, sort_dicts=False, **kwds)

--
resolution: later -> 
versions:  -Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-04 Thread Joachim Jablon


Joachim Jablon  added the comment:

If you stop sorting keys in pprint, then unittest.TestCase.assertDictEquals() 
(and pytest and such) won't be able to generate a meaningful diff when 2 dicts 
aren't equal, and it will be much more complicated to understand why a test 
fails.

https://github.com/python/cpython/blob/89427cd0feae25bbc8693abdccfa6a8c81a2689c/Lib/unittest/case.py#L1172-L1175

(well except if we fix unittest, but then external test runners will need 
fixing too, and it might not be the only place diff is used on the result of 
pprint to see how two objects differ)

--
nosy: +ewjoachim

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-01 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3/library/pprint.html

> Dictionaries are sorted by key before the display is computed.

https://mail.python.org/pipermail/python-dev/2017-December/151369.html . There 
was some discussion in the thread about this being a breaking change and the 
behavior of pprint. @remi.lapeyre I would suggest waiting for a core dev on 
approving this change before proceeding with a patch to avoid work being wasted.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-02-01 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Hi josephsmeng, dict order preservation is now used in a lot of place in 
Python. I will post a patch to make pprint use insertion order in a few hours.

--
nosy: +remi.lapeyre

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-01-30 Thread Joseph Shen


Joseph Shen  added the comment:

I reopened this issue, and change affected versions to 3.6, 3.7 and 3.8.

--
status: closed -> open
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2019-01-30 Thread Valentin Beyer


Valentin Beyer  added the comment:

Please reopen this.
With version 3.7 and guaranteed dict order pprint should not sort by key.

--
nosy: +Valentin Beyer

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2018-10-17 Thread Jan-Hein Bührman

Jan-Hein Bührman  added the comment:

@terry.reedy - If I understand correctly, this issue was closed by you awaiting 
what would happen with the dict insertion order after 3.6.

It has been decided that dict insertion will stay for now and in the future. 
>>> Should this issue now be reopened?

And I would favor backward compatibility (key sort order) with an additional 
keyword for pprint to display it "unsorted" order (from pprint perspective, 
insertion order for dicts and OrderedDicts, and whatever other order for 
whatever other dicts).

--
nosy: +Jan-Hein Bührman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2018-01-27 Thread Philippe

Philippe  added the comment:

IMHO since Guido said that dictionary order is guaranteed going forward [1], 
the order should now be preserved in 3.6+ 

Getting a sorted pprint'ed dict in a Py3.6.1 was a surprise to me coming from 
Python2.

The default ordered dict is to me the killer feature of 3 and a major driver to 
migrate from 2.

[1] https://mail.python.org/pipermail/python-dev/2017-December/151286.html

--
nosy: +pombreda

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2017-11-02 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

A year ago I proposed to add a method for detecting whether a dict preserves an 
order and in what sense. [1] But this idea was rejected.

[1] https://mail.python.org/pipermail/python-dev/2016-October/146597.html

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2017-11-02 Thread Aaron Hall

Aaron Hall  added the comment:

If/when order is guaranteed (3.7?) we should have a pprint that respects 
current order, 

-or-

we should get an improved pprint (maybe named pp or print?) that understands 
mappings and other abstract data types.

I had a conversation about pprint at the Python meetup last night. It kinda 
went like this: https://www.youtube.com/watch?v=NpYEJx7PkWE 

Maybe now's the time for improved behavior?

--
nosy: +Aaron Hall

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2017-06-16 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
resolution:  -> later
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2017-06-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Concur with Raymond.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2017-06-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Until dict insertion order is guaranteed, it doesn't make sense to change 
pprint().

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30670] pprint for dict in sorted order or insert order?

2017-06-14 Thread Joseph Shen

New submission from Joseph Shen:

start from 3.6+, dict keys are ordered heir creation order.
the builtin print function works as we expected, but for 
pprint, the keys is sorted. should we using the sorted version
or just obey the creation order as builtin print?

--
components: Library (Lib)
messages: 296056
nosy: josephsmeng
priority: normal
severity: normal
status: open
title: pprint for dict in sorted order or insert order?
type: behavior
versions: Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com