Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-09 Thread Tim Peters
[Tim Delaney ] > Isn't there already always a scan of the iterable to build the keys array > for sorting (even if no key keyword param is specified)? No - `.sort()` is a list method, and as such has nothing to do with arbitrary iterables, just lists (perhaps you're

Re: [Python-ideas] dict(default=int)

2017-03-09 Thread Chris Angelico
On Fri, Mar 10, 2017 at 11:29 AM, Erik wrote: > On 09/03/17 23:04, Spencer Brown wrote: >> >> Might make more sense to be dict.default(int), that way it doesn't >> have redundant dict names. > > > I thought that, too. > >> since you could do {1:2, 3:4}.default(int) > > >

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-09 Thread Chris Barker
On Thu, Mar 9, 2017 at 2:04 AM, Barry Scott wrote: > It was not clear to me that you need to scan the list at the start to make > sure its homogeneous. Given that the type check is so cheap will it > slow the sort if you do the pointer check in the compare code? I am not

Re: [Python-ideas] dict(default=int)

2017-03-09 Thread Chris Barker
>If we really want to make defaultdict feel more "builtin" (and I don't see > >any reason to do so), I'd suggest adding a factory function: > > > >dict.defaultdict(int) > > Nice. > I agree -- what about: dict.sorteddict() ?? make easy access to various built-in dict variations... -CHB --

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-09 Thread Tim Delaney
On 9 March 2017 at 21:04, Barry Scott wrote: > It was not clear to me that you need to scan the list at the start to make > sure its homogeneous. Given that the type check is so cheap will it > slow the sort if you do the pointer check in the compare code? I am not >

Re: [Python-ideas] dict(default=int)

2017-03-09 Thread Barry Warsaw
On Mar 08, 2017, at 05:49 PM, Eric V. Smith wrote: >If we really want to make defaultdict feel more "builtin" (and I don't see >any reason to do so), I'd suggest adding a factory function: > >dict.defaultdict(int) > >Similar in spirit to dict.fromkeys(), except of course returning a >defauldict,

[Python-ideas] Submitted a PR!

2017-03-09 Thread Elliot Gorokhovsky
Just submitted a PR implementing this: https://github.com/python/cpython/pull/582 -- just need someone to review it now :) Thanks for all your feedback, everyone! On Sun, Mar 5, 2017 at 12:19 AM Elliot Gorokhovsky < elliot.gorokhov...@gmail.com> wrote: > (Summary of results: my patch at

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-09 Thread Elliot Gorokhovsky
On Thu, Mar 9, 2017 at 3:04 AM Barry Scott wrote: > > So you do O(nlogn)*2 pointer compares with my suggestion it seems? Which > is smaller the O(n) pointer checks? > Not sure what you mean here... pretty sure your inequality is backwards? Look -- the point is, we

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-09 Thread Barry Scott
> On 8 Mar 2017, at 22:58, Elliot Gorokhovsky > wrote: > > On Wed, Mar 8, 2017 at 2:14 PM Barry > wrote: > Can you assume that list of of type(list[0]) and use that type's optimised > sort? > But in the