I are the appeal, but this really seems too special purpose for yet another
dunder. A SortedList might be a good addition to the statistics package,
however.
I note that with regard to sorting, I suggested a __sort_key dunder so that
the sorting routines could know how to efficiently sort arbitrar
It surely would be helpful. I still find it a bit too single-case oriented.
Maybe having an equivalent __sorting_algo__ property with a value of the
current sorting algorithm would be more general?
There could be a SortingAlgo base class, which could be extended into
classes like:
- SortingAlg
On 4/8/2019 4:48 PM, Barry Scott wrote:
On 8 Apr 2019, at 19:37, Terry Reedy wrote:
On 4/8/2019 5:40 AM, Steven D'Aprano wrote:
On Mon, Apr 08, 2019 at 07:44:41AM +0100, Alex Chamberlain wrote:
I think a better abstraction for a sorted list is a new class, which
implements the Sequence pro
On Mon, 8 Apr 2019 at 22:07, Barry Scott wrote:
>
>
>
> > On 8 Apr 2019, at 19:37, Terry Reedy wrote:
> >
> > On 4/8/2019 5:40 AM, Steven D'Aprano wrote:
> >> On Mon, Apr 08, 2019 at 07:44:41AM +0100, Alex Chamberlain wrote:
> >>> I think a better abstraction for a sorted list is a new class, whi
> On 8 Apr 2019, at 19:37, Terry Reedy wrote:
>
> On 4/8/2019 5:40 AM, Steven D'Aprano wrote:
>> On Mon, Apr 08, 2019 at 07:44:41AM +0100, Alex Chamberlain wrote:
>>> I think a better abstraction for a sorted list is a new class, which
>>> implements the Sequence protocol (and hence can be use
On 4/8/2019 5:40 AM, Steven D'Aprano wrote:
On Mon, Apr 08, 2019 at 07:44:41AM +0100, Alex Chamberlain wrote:
I think a better abstraction for a sorted list is a new class, which
implements the Sequence protocol (and hence can be used in a lot of
existing list contexts), but only exposed mutati
On Mon, Apr 8, 2019, 6:26 AM Steven D'Aprano wrote:
> Given all the points already raised, I think that an explicit SortedList
> might be more appropriate.
>
This one looks cool. I've read about it, but haven't used it:
http://www.grantjenks.com/docs/sortedcontainers/
I think a "sort hint" shou
On Mon, Apr 8, 2019, 5:46 AM Paul Moore wrote:
> Still not convinced this is safe enough to be worth it ;-)
>
I'm convinced it's NOT safe enough to be worth it.
On the other hand, a sortedlist subclass that maintained its invariant
(probably remembering a key) sounds cool. I think there are one
On 4/8/19 6:25 AM, Steven D'Aprano wrote:
> On Mon, Apr 08, 2019 at 02:55:54AM -0700, Nathaniel Smith wrote:
>> If only we had some kind of API that could compute multiple quantiles at
>> the same time...
>
> You mean something like this?
>
> quartiles, quintiles, deciles, percentiles = quan
On Mon, 8 Apr 2019 at 11:27, Steven D'Aprano wrote:
>
> Fair enough, but does it help you feel a bit better about the feature if
> we called it a "sort hint", and emphasized that it should only be used
> in the same sort of APIs where you might allow the caller to pass
>
> already_sorted=True
On Mon, Apr 08, 2019 at 10:34:19AM +0100, Paul Moore wrote:
> On Mon, 8 Apr 2019 at 10:10, Steven D'Aprano wrote:
>
> > Possibly the maintainer of bisect may decide that its not worth the
> > change. But for the statistics module, I would certainly change the
> > implementation of median() to loo
On Mon, Apr 08, 2019 at 02:55:54AM -0700, Nathaniel Smith wrote:
> Right, by "doesn't affect" I meant "cannot get any benefit, even if their
> code is modified".
Ah, sorry I misunderstood you.
> > # This only makes sense if data is a sequence (list)
> > # not an iterator.
> > quarti
On Mon, Apr 8, 2019, 02:09 Steven D'Aprano wrote:
> On Sun, Apr 07, 2019 at 08:26:24PM -0700, Nathaniel Smith wrote:
> > On Sun, Apr 7, 2019 at 7:37 PM Steven D'Aprano
> wrote:
> > > There are quite a few important algorithms which require lists to be
> > > sorted. For example, the bisect module
On Mon, 8 Apr 2019 at 10:34, Steven D'Aprano wrote:
> The median (and soon, quantiles) API says:
>
> I'm going to sort the list for you, whether you need it or
> not, just in case you do.
Hmm, I didn't see that mentioned in the docs. It makes a difference to
my comment about behaviour cha
On Mon, Apr 08, 2019 at 07:44:41AM +0100, Alex Chamberlain wrote:
> I think a better abstraction for a sorted list is a new class, which
> implements the Sequence protocol (and hence can be used in a lot of
> existing list contexts), but only exposed mutation methods that can
> guarantee that sort
On Mon, 8 Apr 2019 at 10:10, Steven D'Aprano wrote:
> Possibly the maintainer of bisect may decide that its not worth the
> change. But for the statistics module, I would certainly change the
> implementation of median() to look something vaguely like this:
>
> # was
> data = sorted(data)
On Mon, Apr 08, 2019 at 03:18:53PM +1000, Cameron Simpson wrote:
> If this is a publicly queriable value, is there any need to have a
> dunder name at all? Why not just give lists a public is_sorted
> attribute?
I don't mind that.
> I'm also not convinced the cost to every insert/append is wo
On Mon, Apr 08, 2019 at 01:31:14PM +1000, Cameron Simpson wrote:
> __setitem__ concerns me, along with other modification methods: what
> about subclasses(*)? Every existing subclass which overrides __setitem__
> now needs to grow code to maintain __issorted__ if they do not
> themselves call l
On Sun, Apr 07, 2019 at 08:26:24PM -0700, Nathaniel Smith wrote:
> On Sun, Apr 7, 2019 at 7:37 PM Steven D'Aprano wrote:
> > There are quite a few important algorithms which require lists to be
> > sorted. For example, the bisect module, and for statistics median and
> > other quantiles.
>
> But
looks for me that means that all subclass of list has to maintain the
__isorted__ invariant,
looks like not a backward compatible modification and quite problematic
in case of the invariant broken.
So if I'm correct the design is brittle.
Moreover, that solve only the strict subset of sort case w
Basically, I like this idea and of course theoretically it has use cases. But
in the proposed form, it feels strongly curtailed. In practice, what does
it mean to be sorted?
[('a', 1),('b', 2),('bb', 4),('aaa', 3)] # Is this list sorted?
[('a', 1),('aaa', 3),('b', 2),('bb', 4)] # or this?
[('a',
On Mon, 8 Apr 2019 at 06:19, Cameron Simpson wrote:
>
> On 08Apr2019 00:17, Terry Reedy wrote:
> >On 4/7/2019 10:32 PM, Steven D'Aprano wrote:
> >>There are quite a few important algorithms which require lists to be
> >>sorted. [...]
> >>Proposal: let's give lists a dunder flag, __issorted__, tha
On 08Apr2019 00:17, Terry Reedy wrote:
On 4/7/2019 10:32 PM, Steven D'Aprano wrote:
There are quite a few important algorithms which require lists to be
sorted. [...]
Proposal: let's give lists a dunder flag, __issorted__, that tracks
whether the list is definitely sorted or not:
[...] Dunder
On 4/7/2019 10:32 PM, Steven D'Aprano wrote:
There are quite a few important algorithms which require lists to be
sorted. For example, the bisect module, and for statistics median and
other quantiles.
Sorting a list is potentially expensive: while Timsort is very
efficient, it is still ultimatel
On 08Apr2019 12:32, Steven D'Aprano wrote:
There are quite a few important algorithms which require lists to be
sorted. For example, the bisect module, and for statistics median and
other quantiles.
Sorting a list is potentially expensive: while Timsort is very
efficient, it is still ultimately
On Sun, Apr 7, 2019 at 7:37 PM Steven D'Aprano wrote:
> There are quite a few important algorithms which require lists to be
> sorted. For example, the bisect module, and for statistics median and
> other quantiles.
But this flag doesn't affect those modules, right? 'bisect' already
requires the
There are quite a few important algorithms which require lists to be
sorted. For example, the bisect module, and for statistics median and
other quantiles.
Sorting a list is potentially expensive: while Timsort is very
efficient, it is still ultimately an O(N log N) algorithm which limits
how
27 matches
Mail list logo