[Python-ideas] Make list.reverse() more flexible

2021-03-05 Thread Vincent Cheong
Currently, list.reverse() only works for an entire list. If one wants to reverse a section of it 'in-place', one needs to slicing which makes the space complexity no longer O(1). One can also manually make a loop and do the reversal but that is even slower than slicing. List.reverse() does not t

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread 2QdxY4RzWzUUiLuE
On 2021-03-05 at 16:27:27 -, Vincent Cheong wrote: > Currently, list.reverse() only works for an entire list. If one wants > to reverse a section of it 'in-place', one needs to slicing which > makes the space complexity no longer O(1). One can also manually make > a loop and do the reversal b

[Python-ideas] Re: Add an __exclude_all__ complement to __all__

2021-03-05 Thread Marco Sulla
On Wed, 3 Mar 2021 at 23:59, Brendan Barnwell wrote: > But usually you want to define it at the beginning as a sort of > documentation aid ("this is the public API"). This is a little off-topic, but I'm curious, since usually, for public functions and classes, I do __all__ = (Class.__name__, fu

[Python-ideas] Re: Add an __exclude_all__ complement to __all__

2021-03-05 Thread Caleb Donovick
> __all__ = (Class.__name__, func.__name__, ...) > > So I have to put it at the end of the module. I do this because if I > change the class or function name and I forget to change it in > __all__, I get an exception. I certainly will not claim to be the arbitrator of good and bad practices but th

[Python-ideas] Re: Add an __exclude_all__ complement to __all__

2021-03-05 Thread Ethan Furman
On 3/5/21 12:41 PM, Caleb Donovick wrote: > __all__ = (Class.__name__, func.__name__, ...) > > So I have to put it at the end of the module. I do this because if I > change the class or function name and I forget to change it in > __all__, I get an exception. I certainly will not claim to

[Python-ideas] Re: Add an __exclude_all__ complement to __all__

2021-03-05 Thread Chris Angelico
On Sat, Mar 6, 2021 at 9:47 AM Ethan Furman wrote: > > On 3/5/21 12:41 PM, Caleb Donovick wrote: > > > > > __all__ = (Class.__name__, func.__name__, ...) > > > > > > So I have to put it at the end of the module. I do this because if I > > > change the class or function name and I forget to cha

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread Steven D'Aprano
On Fri, Mar 05, 2021 at 04:27:27PM -, Vincent Cheong wrote: > Currently, list.reverse() only works for an entire list. If one wants > to reverse a section of it 'in-place', one needs to slicing which > makes the space complexity no longer O(1). The space complexity of a list is not constant

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread Vincent Cheong
Sorry for not explaining the background of my idea. I'm involved in the research area of sorting algorithms. Reversals are part of sorting and correct me if wrong, `list.reverse()` is the fastest method to reverse an entire list, which is also in-place. Yet, it doesn't work for a subsection of i

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread David Mertz
This sounds like a very verbose repeated statement that "there may be a use in the future." That's definitely not going to get a feature, no matter how many times repeated. If this is something you actually need, write a subclass of list in Cython or C, and add that capability. I cannot think of a

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread Vincent Cheong
[This is the revised version of the previous reply which contained mistakes] Sorry for not explaining the background of my idea. I'm involved in the research area of sorting algorithms. Reversals are part of sorting and correct me if wrong, `list.reverse()` is the fastest method to reverse an en

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread David Mertz
On Sat, Mar 6, 2021 at 7:07 AM David Mertz wrote: > This sounds like a very verbose repeated statement that "there may be a > use in the future." That's definitely not going to get a feature, no matter > how many times repeated. > > If this is something you actually need, write a subclass of list

[Python-ideas] Re: Make list.reverse() more flexible

2021-03-05 Thread Vincent Cheong
I see. I do agree that my reply brings about that 'verbose repeated' feeling, haha. But for the record, it's not about having something in hand now for the future, but it's more of a paradigmatic approach to the implementation. Python has changed for the better in terms of necessity: - map() re