[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-07 Thread Dan Stromberg
On Mon, Jun 7, 2021 at 11:20 AM Tim Peters wrote: > [Dan Stromberg ] > > ... > > Timsort added the innovation of making mergesort in-place, plus a little > > (though already common) O(*n^2) sorting for small sublists. > > Actually, both were already very common in mergesorts. "timsort" is > much

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-07 Thread Tim Peters
[Dan Stromberg ] > ... > Timsort added the innovation of making mergesort in-place, plus a little > (though already common) O(*n^2) sorting for small sublists. Actually, both were already very common in mergesorts. "timsort" is much more a work of engineering than of insight ;-) That is, it

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-07 Thread Kyle Stanley
On Sun, Jun 6, 2021 at 7:09 PM Dan Stromberg wrote: > I've got a comparison of sort algorithms in both Cython and Pure Python > (your choice) at: > https://stromberg.dnsalias.org/~strombrg/sort-comparison/ > ...including a version of timsort that is in Cython or Pure Python. > Thanks for

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-07 Thread Antoine Pitrou
On Mon, 7 Jun 2021 06:49:24 -0700 Senthil Kumaran wrote: > On Sun, Jun 06, 2021 at 04:07:57PM -0700, Dan Stromberg wrote: > > I've got a comparison of sort algorithms in both Cython and Pure Python > > (your > > choice) at: > > https://stromberg.dnsalias.org/~strombrg/sort-comparison/  > >

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-07 Thread Senthil Kumaran
On Sun, Jun 06, 2021 at 04:07:57PM -0700, Dan Stromberg wrote: > I've got a comparison of sort algorithms in both Cython and Pure Python (your > choice) at: > https://stromberg.dnsalias.org/~strombrg/sort-comparison/  > ...including a version of timsort that is in Cython or Pure Python. >

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-06 Thread Dan Stromberg
On Sun, Jun 6, 2021 at 2:46 AM Marco Sulla wrote: > As title. Is it faster for inplace sorting, or simply the > implementation of list.sort() was done before the implementation of > timsort? > As you already know, timsort is pretty close to merge sort. Timsort added the innovation of making

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-06 Thread Marco Sulla
On Sun, 6 Jun 2021 at 11:57, Christian Heimes wrote: > > On 06/06/2021 11.42, Marco Sulla wrote: > > As title. Is it faster for inplace sorting, or simply the > > implementation of list.sort() was done before the implementation of > > timsort? > > list.sort() uses timsort. What makes you think

[Python-Dev] Re: Why list.sort() uses mergesort and not timsort?

2021-06-06 Thread Christian Heimes
On 06/06/2021 11.42, Marco Sulla wrote: > As title. Is it faster for inplace sorting, or simply the > implementation of list.sort() was done before the implementation of > timsort? list.sort() uses timsort. What makes you think that Python uses mergesort? Tim Peters invented timsort for Python