[Python-ideas] Optimizing list.sort() by checking type in advance

Chris Angelico rosuav at gmail.com
Mon Oct 10 23:37:51 EDT 2016


On Tue, Oct 11, 2016 at 2:29 PM, Elliot Gorokhovsky
<elliot.gorokhovsky at gmail.com> wrote:
> Ya, I think this may be a good approach for floats: if the list is all
> floats, just copy all the floats into a seperate array, use the standard
> library quicksort, and then construct a sorted PyObject* array. Like maybe
> set up a struct { PyObject* payload, float key } type of deal.

Not quite sure what you mean here. What is payload, what is key? Are
you implying that the original float objects could be destroyed and
replaced with others of equal value? Python (unlike insurance claims)
guarantees that you get back the exact same object as you started
with.

ChrisA


More information about the Python-ideas mailing list