A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/038722.html below:

[Python-Dev] decorate-sort-undecorate

[Python-Dev] decorate-sort-undecorateGuido van Rossum guido at python.org
Tue Oct 14 15:19:22 EDT 2003
> I would rather wrap Tim's existing code than muck with assignment logic.
> Ideally, the performance of list.sort() should stay unchanged when the
> key function is not specified.

Impossible -- the aux objects tax the memory cache more.  Also the
characteristics of the data will be very different.

> Tim's original (key, index, value) idea seems to be simplest.  The only
> sticking point is the immortality of PyInts.  One easy, but not so
> elegant way around this is to use another mortal object for a tiebreaker
> (for example, "00000", "00001", ...).  Alternatively, is there a way of
> telling a PyInt to be mortal?

I still like custom objects better.

> Besides immortality and speed, another consideration is the interaction
> between the cmp function and the key function.  If both are specified,
> then the underlying decoration becomes visible to the user:
> 
>     def viewcmp(a, b):
>         print a, b  # the decoration just became visible
>         return cmp(a,b)
>     mylist.sort(cmp=viewcmp, key=str.lower)
> 
> Since the decoration can be visible, it should be as understandable as
> possible.  Viewed this way, PyInts are preferable to a custom object.

I think we should disallow specifying both cmp and key arguments.
Using both just doesn't make sense.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4