Re: [Python-ideas] Add "equal" builtin function

2016-10-07 Thread Nick Coghlan
On 6 October 2016 at 23:45, Filipp Bakanov wrote: > For now there are many usefull builtin functions like "any", "all", etc. I'd > like to propose a new builtin function "equal". It should accept iterable, > and return True if all items in iterable are the same or iterable is emty. If the items a

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Paul Moore
On 6 October 2016 at 18:09, Filipp Bakanov wrote: > Seems like itertools recipes already have "all_equal" function. What do you > think about moving it from recipes to itertools? I suggest a C > implementation with optimisations for builtin collections. Interestingly, the recipe given there was n

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Mark Lawrence via Python-ideas
On 06/10/2016 15:43, Sjoerd Job Postmus wrote: On Thu, Oct 06, 2016 at 03:01:36PM +0100, Paul Moore wrote: On 6 October 2016 at 14:45, Filipp Bakanov wrote: For now there are many usefull builtin functions like "any", "all", etc. I'd like to propose a new builtin function "equal". It should ac

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread אלעזר
The name might be a little confusing; it can be understood as comparing two sequences, so passing two sequences may seem reasonable to a reviewer. Elazar בתאריך יום ה׳, 6 באוק' 2016, 20:15, מאת Filipp Bakanov ‏: > Seems like itertools recipes already have "all_equal" function. What do > you thin

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Filipp Bakanov
Seems like itertools recipes already have "all_equal" function. What do you think about moving it from recipes to itertools? I suggest a C implementation with optimisations for builtin collections. 2016-10-06 18:42 GMT+03:00 Chris Angelico : > On Fri, Oct 7, 2016 at 2:23 AM, Steven D'Aprano > wr

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Chris Angelico
On Fri, Oct 7, 2016 at 2:23 AM, Steven D'Aprano wrote: > +0.3 to adding it the standard library. > > +0.1 to adding it to built-ins > > -0.1 on adding it to built-ins under the name "equal", as that will > confuse too many people. I'll go further: -0.5 on adding to built-ins. +0.5 on adding it to

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Ethan Furman
On 10/06/2016 06:45 AM, Filipp Bakanov wrote: For now there are many usefull builtin functions like "any", "all", etc. I'd like to propose a new builtin function "equal". It should accept iterable, and return True if all items in iterable are the same or iterable is emty. That's quite popula

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Steven D'Aprano
On Thu, Oct 06, 2016 at 04:45:01PM +0300, Filipp Bakanov wrote: > For now there are many usefull builtin functions like "any", "all", etc. > I'd like to propose a new builtin function "equal". It should accept > iterable, and return True if all items in iterable are the same or iterable > is emty.

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread אלעזר
On Thu, Oct 6, 2016 at 5:53 PM Sjoerd Job Postmus wrote: > On Thu, Oct 06, 2016 at 02:45:11PM +, אלעזר wrote: > > It is a real problem. People are used to write `seq == [1, 2, 3]` and it > > passes unnoticed (even with type checkers) that if seq changes to e.g. a > > tuple, it will cause subt

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Sjoerd Job Postmus
On Thu, Oct 06, 2016 at 02:45:11PM +, אלעזר wrote: > It is a real problem. People are used to write `seq == [1, 2, 3]` and it > passes unnoticed (even with type checkers) that if seq changes to e.g. a > tuple, it will cause subtle bugs. It is inconvenient to write `len(seq) == > 3 and seq == [1

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Sjoerd Job Postmus
On Thu, Oct 06, 2016 at 03:01:36PM +0100, Paul Moore wrote: > On 6 October 2016 at 14:45, Filipp Bakanov wrote: > > For now there are many usefull builtin functions like "any", "all", etc. I'd > > like to propose a new builtin function "equal". It should accept iterable, > > and return True if all

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread אלעזר
It is a real problem. People are used to write `seq == [1, 2, 3]` and it passes unnoticed (even with type checkers) that if seq changes to e.g. a tuple, it will cause subtle bugs. It is inconvenient to write `len(seq) == 3 and seq == [1, 2, 3]` and people often don't notice the need to write it. (

Re: [Python-ideas] Add "equal" builtin function

2016-10-06 Thread Paul Moore
On 6 October 2016 at 14:45, Filipp Bakanov wrote: > For now there are many usefull builtin functions like "any", "all", etc. I'd > like to propose a new builtin function "equal". It should accept iterable, > and return True if all items in iterable are the same or iterable is emty. > That's quite

[Python-ideas] Add "equal" builtin function

2016-10-06 Thread Filipp Bakanov
For now there are many usefull builtin functions like "any", "all", etc. I'd like to propose a new builtin function "equal". It should accept iterable, and return True if all items in iterable are the same or iterable is emty. That's quite popular problem, there is a discussion of how to perform it