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

2021-12-26 Thread Stefan Pochmann
Steven D'Aprano wrote: > Can you sketch an O(n) algorithm for removing multiple items from an > array, which *doesn't* involving building a temporary new list? Here's what I meant. Have read/write indexes, delete the gap after maxcount occurrences: def remove(lst, value, maxcount): read = w

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

2021-12-26 Thread Stefan Pochmann
Steven D'Aprano wrote: > Or simpler still: Yes, I didn't try to make it "simpler", but intentionally kept the transformations as-is. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] h

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

2021-12-26 Thread Stephen J. Turnbull
Stefan Pochmann writes: > Steven D'Aprano wrote: > > Or simpler still: > > Yes, I didn't try to make it "simpler", but intentionally kept the > transformations as-is. But you didn't, really. As-is would use genexps to "inline" the map and filter calls: list(x for x in (y + 1 for y in