Re: Incompatible change discussion: Pretty printing of ordered dict.
Dirk Boonzajer Flaes <[email protected]> Wed, 2 Aug 2017 23:24:54 +0200
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <CAOtuR0Z61xWi8ninhGerszPVG01SAc8JrFUey0tZENTzBzC6tw@mail.gmail.com> |
--===============6013191613086586651== Content-Type: multipart/alternative; boundary="001a11443fda31c1120555cbe573" --001a11443fda31c1120555cbe573 Content-Type: text/plain; charset="UTF-8" I am pretty experienced with numpy but I wasn't with using dicts, and this 'feature" confused me a lot! I would be all for removing the sorting to make it clear that the order is not preserved, although it does make displaying dicts a bit less clear. On Aug 2, 2017 10:33 PM, "Thomas Kluyver" <[email protected]> wrote: > I don't have a particular concrete use case, but as an experienced Python > programmer who knows that dicts are conceptually unordered, I like the > sorted presentation and would be sorry to lose it. It makes it easier to > quickly find something in a dict if its shown in alphabetical order. > > If the dict maintaining insertion order becomes a language feature rather > than an implementation detail, I would favour showing that. But for now > it's an implementation detail, so it shouldn't change how we think about > dicts. > > Thomas > > On 2 August 2017 at 19:44, Matthias Bussonnier < > [email protected]> wrote: > >> Hi all, >> >> As you may or may not be aware, with Python 3.6 the dictionary are >> ordered by default. It is technically an implementation detail, though >> some people would love for it not to. >> >> Regardless, IPython has for a long time pretty-printed the dictionary >> with _sorted_ keys, this thus prevent to teach python and show that >> dictionaries maintain order. Thus there is the question of wether we >> should disable sorting keys while pretty-printing. >> >> https://github.com/ipython/ipython/issues/10110 >> >> This seem like a minor change, but I'd like to know if some of you are >> _relying_ on the ordering of dict when they are printed, or have >> compelling arguments against (or for) removing sorting of the keys >> before pretty_printing. >> >> If you care about the above subject, please have your voice heard in >> above issue. >> >> Thanks, >> -- >> Matthias >> _______________________________________________ >> IPython-dev mailing list >> [email protected] >> https://mail.python.org/mailman/listinfo/ipython-dev >> > > > _______________________________________________ > IPython-dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/ipython-dev > > --001a11443fda31c1120555cbe573 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><br>I am pretty experienced with numpy but I wasn't w= ith using dicts, and this 'feature" confused me a lot! I would =C2= =A0be all for removing the sorting to make it clear that the order is not p= reserved, although it does make displaying dicts a bit less clear.</div><di= v class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Aug 2, 2017 10:33= PM, "Thomas Kluyver" <<a href=3D"mailto:[email protected]">tak= [email protected]</a>> wrote:<br type=3D"attribution"><blockquote class=3D"g= mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l= eft:1ex"><div dir=3D"ltr"><div><div>I don't have a particular concrete = use case, but as an experienced Python programmer who knows that dicts are = conceptually unordered, I like the sorted presentation and would be sorry t= o lose it. It makes it easier to quickly find something in a dict if its sh= own in alphabetical order.<br><br></div>If the dict maintaining insertion o= rder becomes a language feature rather than an implementation detail, I wou= ld favour showing that. But for now it's an implementation detail, so i= t shouldn't change how we think about dicts.<br><br></div>Thomas<br></d= iv><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 2 August 20= 17 at 19:44, Matthias Bussonnier <span dir=3D"ltr"><<a href=3D"mailto:bu= [email protected]" target=3D"_blank">[email protected]<= /a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:= 0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br> <br> As you may or may not be aware, with Python 3.6 the dictionary are<br> ordered by default. It is technically an implementation detail, though<br> some people would love for it not to.<br> <br> Regardless, IPython has for a long time pretty-printed the dictionary<br> with _sorted_ keys, this thus prevent to teach python and show that<br> dictionaries maintain order. Thus there is the question of wether we<br> should disable sorting keys while pretty-printing.<br> <br> <a href=3D"https://github.com/ipython/ipython/issues/10110" rel=3D"noreferr= er" target=3D"_blank">https://github.com/ipython/ipy<wbr>thon/issues/10110<= /a><br> <br> This seem like a minor change, but I'd like to know if some of you are<= br> _relying_ on the ordering of dict when they are printed, or have<br> compelling arguments against (or for) removing sorting of the keys<br> before pretty_printing.<br> <br> If you care about the above subject, please have your voice heard in<br> above issue.<br> <br> Thanks,<br> <span class=3D"m_7568958421120238038HOEnZb"><font color=3D"#888888">--<br> Matthias<br> ______________________________<wbr>_________________<br> IPython-dev mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">IPython-dev@pyt= hon.org</a><br> <a href=3D"https://mail.python.org/mailman/listinfo/ipython-dev" rel=3D"nor= eferrer" target=3D"_blank">https://mail.python.org/mailma<wbr>n/listinfo/ip= ython-dev</a><br> </font></span></blockquote></div><br></div> <br>______________________________<wbr>_________________<br> IPython-dev mailing list<br> <a href=3D"mailto:[email protected]">[email protected]</a><br> <a href=3D"https://mail.python.org/mailman/listinfo/ipython-dev" rel=3D"nor= eferrer" target=3D"_blank">https://mail.python.org/<wbr>mailman/listinfo/ip= ython-dev</a><br> <br></blockquote></div></div> --001a11443fda31c1120555cbe573-- --===============6013191613086586651== 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 --===============6013191613086586651==--