Re: display of dicts?

Thomas Kluyver <[email protected]> Tue, 19 Dec 2017 17:37:55 +0000
Newsgroups gmane.comp.python.ipython.devel
Message-ID <CAOvn4qi8tp=P33ehyLk2i0D7pigeU1WTGKC9snWO9HuFSptXQQ@mail.gmail.com>
--===============1046248703686012075==
Content-Type: multipart/alternative; boundary="94eb2c1c029c2da3c10560b4efbb"

--94eb2c1c029c2da3c10560b4efbb
Content-Type: text/plain; charset="UTF-8"

On 19 December 2017 at 17:24, Chris Barker <[email protected]> wrote:

> Granted, string keys where alphabetization makes sense are pretty darn
> common, but still a "special case"
>

I'd argue that they're common enough to be the typical case, though perhaps
my definition of 'makes sense' is a bit broader than yours. And sorting can
also make sense for numeric keys.


> In fact, I discovered this with this example, which I used in my intro to
> Python class to demonstrate dict's arbitrary order
>

I think this is exactly the tension we're facing. People teaching intro to
Python courses want to show what a dictionary *is*, and you don't want
IPython's features to obscure that. But other than learning about
dictionaries, I suspect that sorted order is useful more often than
insertion order.

I'm leaning slightly towards making insertion order the default in Python
3.7 - it will be meaningful some of the time, and it is now part of what a
dict is - but I think we should ensure the same release adds an easy way to
switch back to displaying sorted dicts.

Thomas

--94eb2c1c029c2da3c10560b4efbb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1=
9 December 2017 at 17:24, Chris Barker <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:[email protected]" target=3D"_blank">[email protected]</a>&gt;<=
/span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><div>Granted, string keys where=
 alphabetization makes sense are pretty darn common, but still a &quot;spec=
ial case&quot;</div></div></div></div></blockquote><div><br></div><div>I&#3=
9;d argue that they&#39;re common enough to be the typical case, though per=
haps my definition of &#39;makes sense&#39; is a bit broader than yours. An=
d sorting can also make sense for numeric keys.<br></div><div>=C2=A0</div><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><=
div class=3D"gmail_quote"><div></div><div>In fact, I discovered this with t=
his example, which I used in my intro to Python class to demonstrate dict&#=
39;s arbitrary order</div></div></div></div></blockquote><div><br></div><di=
v>I think this is exactly the tension we&#39;re facing. People teaching int=
ro to Python courses want to show what a dictionary *is*, and you don&#39;t=
 want IPython&#39;s features to obscure that. But other than learning about=
 dictionaries, I suspect that sorted order is useful more often than insert=
ion order.</div><div><br></div><div>I&#39;m leaning slightly towards making=
 insertion order the default in Python 3.7 - it will be meaningful some of =
the time, and it is now part of what a dict is - but I think we should ensu=
re the same release adds an easy way to switch back to displaying sorted di=
cts.</div><div><br></div><div>Thomas<br></div><br></div></div></div>

--94eb2c1c029c2da3c10560b4efbb--

--===============1046248703686012075==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
IPython-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/ipython-dev

--===============1046248703686012075==--