[Python-Dev] Tips on C and the CPython Codebase

2021-10-30 Thread Abdur-Rahmaan Janhangeer
Greetings list, I am going to start tinkering with the Python source again (on Linux) I previously built the source etc using Visual Studio on Windows Now the EFL ui libs re-ignited my passion for C while playing with python-efl And Chris last proposal made me want to re-play with the CPython code

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Steven D'Aprano
On Sun, Oct 31, 2021 at 01:32:29PM +1300, Greg Ewing wrote: > On 31/10/21 5:47 am, Raymond Bisdorff wrote: > >Should the tuples comparison is in this case, I thought, not be solely > >based on the first tuple component? > > Whether you think it should or shouldn't, the fact is that it's not. > Th

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Greg Ewing
On 31/10/21 5:47 am, Raymond Bisdorff wrote: Should the tuples comparison is in this case, I thought, not be solely based on the first tuple component? Whether you think it should or shouldn't, the fact is that it's not. This is documented in Section 5.6 of the Library Reference: "tuples and l

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Raymond Bisdorff
Dear All, You are all completely right. Sorry for the confusion. Thank you all very much for putting my mind right about this issue. Best Regards Raymond Bisdorff > On 30 Oct 2021, at 19:00, Tim Peters wrote: > > [Raymond Bisdorff ] >> I fully agree with your point. By default, all the com

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Paul Ganssle
You are re-assigning the list on line 4 here, not displaying it. I get the answer you expect when using the `itemgetter(0)` key: IPython 7.28.0, on CPython 3.9.7 (default, Aug 31 2021 13:28:12) >>> import operator >>> from operator import itemgetter >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Tim Peters
[Raymond Bisdorff ] > I fully agree with your point. By default, all the components of the > tuple should be used in the comparison. > > Yet, I was confused by the following result. > >>> from operator import itemgetter > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> L.sort(ke

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Raymond Bisdorff
Dear All, I fully agree with your point. By default, all the components of the tuple should be used in the comparison. Yet, I was confused by the following result. >>> from operator import itemgetter >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] >>> L.sort(key=itemgetter(0), rever

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Evpok Padding
Hi, On Sat, 30 Oct 2021 at 16:23, Raymond Bisdorff wrote: > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> L.sort(reverse=True) > >>> L > >>> [(3, 'e'), (2, 'd'), (2, 'b'), (1, 'c'), (1, 'a')] > > it should be: > > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Richard Damon
On 10/30/21 11:46 AM, Raymond Bisdorff wrote: Dear Python developers, The help(list) shows in a python console the following documentation string for the list.sort() method. sort(self, /, *, key=None, reverse=False)  |  Sort the list in ascending order and return None.  |  |  The sort

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Tim Peters
[Raymond Bisdorff ] > ... > Please notice the following inconsistency in Python3.10.0 and before of > a sort(reverse=True) result: > > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> L.sort(reverse=True) > >>> L > >>> [(3, 'e'), (2, 'd'), (2, 'b'), (1, 'c'), (1, 'a')] Looks go

[Python-Dev] The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Raymond Bisdorff
Dear Python developers, The help(list) shows in a python console the following documentation string for the list.sort() method. sort(self, /, *, key=None, reverse=False)  |  Sort the list in ascending order and return None.  |  |  The sort is in-place (i.e. the list itself is modified)