Benjamin Peterson added the comment:
On Wed, Apr 29, 2015, at 13:25, Sergey B Kirpichev wrote:
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 03:25:19PM +, Benjamin Peterson wrote:
So, basically you need a base case for recursion? What's wrong with
explicitly writing
Paul Moore added the comment:
I think the documentation is fine:
The key corresponding to each item in the list is calculated once and then used
for the entire sorting process.
This corresponds with the standard decorate-sort-undecorate approach to
handling key functions in sorts. It's a
Paul Moore added the comment:
On 29 April 2015 at 19:42, Sergey B Kirpichev rep...@bugs.python.org wrote:
It's a common computer science technique
Could you provide any language that avoid this optimization?
Here is Perl 5:
http://perl5.git.perl.org/perl.git/blob/HEAD:/pp_sort.c#l367
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 03:25:19PM +, Benjamin Peterson wrote:
So, basically you need a base case for recursion? What's wrong with
explicitly writing that out?
Because it's complex (and costly). This is not a trivial test and
I don't see reasons to
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 05:44:22PM +, Paul Moore wrote:
I think the documentation is fine:
The key corresponding to each item in the list is calculated once and then
used for the entire sorting process.
Does any sorting process make sense for
Changes by Sergey B Kirpichev skirpic...@gmail.com:
Added file:
http://bugs.python.org/file39232/0001-list.sort-Add-quick-exit-if-length-of-list-1.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 06:51:21PM +, Paul Moore wrote:
But that's a sort without a key.
Why it does matter? It have quick exit. For same reasons - Python could...
In Perl you do a key sort via:
That's just your implementation. But we could add
New submission from Sergey B Kirpichev:
If there is nothing to sort (i.e. one item), why call key function at all?
In my practical situation, simplest key() function will lead to recursion in
case of such trivial lists. I can make similar cmp-type function (i.e.
mycmp=lambda a, b:
Stéphane Wirtel added the comment:
The patch is ok for me,
--
nosy: +matrixise, r.david.murray
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
___
Sergey B Kirpichev added the comment:
should I add a regression test?
If so, where? ./Lib/test/test_sort.py?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
___
Raymond Hettinger added the comment:
FWIW, I don't think this is worth special casing.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
___
Changes by Serhiy Storchaka storch...@gmail.com:
--
nosy: +rhettinger, tim.peters
stage: - patch review
type: behavior - performance
versions: -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.6
___
Python tracker rep...@bugs.python.org
Benjamin Peterson added the comment:
Why does your key function depend on the size of the list? That seems like the
root of the problem. Considering calling the key function is observable
behavior, I don't think this should be changed. The patch makes behavior
list.sort() inconsistent.
Stéphane Wirtel added the comment:
Yep, add a regression test.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
___
___
Python-bugs-list
Benjamin Peterson added the comment:
On Wed, Apr 29, 2015, at 11:03, Sergey B Kirpichev wrote:
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 02:32:34PM +, Benjamin Peterson wrote:
Why does your key function depend on the size of the list?
Because it's a real life.
Mark Dickinson added the comment:
I should also clarify that Raymond and Mark and responsible for
maintaining most of the algorithmic/data structure code in Python.
Well, Raymond at least. I plead not guilty; I think you're confusing me with
someone else. :-)
But for this issue, this
Mark Dickinson added the comment:
Considering calling the key function is observable behavior, I don't think
this should be changed.
+1
--
nosy: +mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
Changes by Benjamin Peterson benja...@python.org:
--
resolution: - rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24075
___
Sergey B Kirpichev added the comment:
On Wed, Apr 29, 2015 at 02:32:34PM +, Benjamin Peterson wrote:
Why does your key function depend on the size of the list?
Because it's a real life. Here is the code:
https://github.com/skirpichev/omg/blob/gruntz-use-subs/sympy/series/gruntz.py#L337
19 matches
Mail list logo