[Python-ideas] Re: dict.sort()?

2021-05-30 Thread Stephen J. Turnbull
Jonathan Fine writes: > tmp = list(sorted(d.items())) The list() call is redundant. sorted() always returns a new list. Ditto, reversed(). The method versions are in-place. Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscrib

[Python-ideas] Re: dict.sort()?

2021-05-30 Thread Chris Angelico
On Sun, May 30, 2021 at 5:18 PM Stephen J. Turnbull wrote: > > Jonathan Fine writes: > > > tmp = list(sorted(d.items())) > > The list() call is redundant. sorted() always returns a new list. Correct. > Ditto, reversed(). The method versions are in-place. Not correct - reversed() is a paralle

[Python-ideas] Re: dict.sort()?

2021-05-30 Thread Stephen J. Turnbull
Chris Angelico writes: > > Ditto, reversed(). The method versions are in-place. > > Not correct - reversed() is a parallel to iter() and returns a > reversed iterator. Opps, I knew that too -- once upon a time. Thanks for the correction! ___ Pyt

[Python-ideas] Re: dict.sort()?

2021-05-30 Thread Chris Angelico
On Mon, May 31, 2021 at 12:19 AM Stephen J. Turnbull wrote: > > Chris Angelico writes: > > > > Ditto, reversed(). The method versions are in-place. > > > > Not correct - reversed() is a parallel to iter() and returns a > > reversed iterator. > > Opps, I knew that too -- once upon a time. Tha