[Python-Dev] Python3 regret about deleting list.sort(cmp=...)
Terry Reedy
tjreedy at udel.edu
Sun Mar 13 02:16:27 CET 2011
On 3/12/2011 5:09 PM, Reid Kleckner wrote:
> On Sat, Mar 12, 2011 at 4:58 PM, Nick Coghlan<ncoghlan at gmail.com> wrote:
>> On Sat, Mar 12, 2011 at 4:50 PM, Reid Kleckner<reid.kleckner at gmail.com> wrote:
>>> They should be able to use a slotted cmp_to_key style class:
>>> http://docs.python.org/howto/sorting.html
>>>
>>> That will allocate 1 Python object with no dict per key, but that
>>> might not be good enough.
>>
>> Tuples are already slotted, so that isn't likely to help in this case.
>
> It's three allocations vs. one. The first is tuple + str + int, while
> the adapter is just one object. I'm not sure how it eventually shakes
> out, though.
>
> That said, it's still worse than Python 2, which is zero allocations. :)
And revising the data so that no key and no cmp function is needed is
zero allocations and faster. See my other post.
--
Terry Jan Reedy
More information about the Python-Dev
mailing list