[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread Steven D'Aprano
On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: > Chris Angelico wrote: > > If you're removing multiple, it's usually best to filter. This is a > > great opportunity to learn about list comprehensions and the > > difference between O(n) and O(n²) :) > > ChrisA > > It would be O(n)

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread MRAB
On 2021-12-25 23:52, Steven D'Aprano wrote: On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: Chris Angelico wrote: > If you're removing multiple, it's usually best to filter. This is a > great opportunity to learn about list comprehensions and the > difference between O(n) and O(

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread Chris Angelico
On Sun, Dec 26, 2021 at 11:00 AM Steven D'Aprano wrote: > > On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: > > Chris Angelico wrote: > > > If you're removing multiple, it's usually best to filter. This is a > > > great opportunity to learn about list comprehensions and the > > >

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread Jeremiah Vivian
Steven D'Aprano wrote: > On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: > > Chris Angelico wrote: > > If you're removing multiple, it's usually best to filter. This is a > > great opportunity to learn about list comprehensions and the > > difference between O(n) and O(n²) :) > > C

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread Chris Angelico
On Sun, Dec 26, 2021 at 11:32 AM Jeremiah Vivian wrote: > > Steven D'Aprano wrote: > > On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: > > > Chris Angelico wrote: > > > If you're removing multiple, it's usually best to filter. This is a > > > great opportunity to learn about list

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread Jeremiah Vivian
Chris Angelico wrote: > On Sun, Dec 26, 2021 at 11:32 AM Jeremiah Vivian > [email protected] wrote: > > Steven D'Aprano wrote: > > On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: > > Chris Angelico wrote: > > If you're removing multiple, it's usually best to filter. This

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-12-25 Thread Steven D'Aprano
On Fri, Dec 24, 2021 at 10:22:29AM -, Stefan Pochmann wrote: > Chris Angelico wrote: > > Here's the equivalent as a list comprehension, which I think looks > > better than either of the above: > > [x + 1 for x in [1,2,3] if x % 2 == 0] > > That's not equivalent. You produce [3] instead of [2,