Record the rejection of PEP 265.
The requested functionality was largely fulfilled by Py2.4's sorted() function. See Guido's 6/17/2005 note on python-dev.
This commit is contained in:
parent
873af4a927
commit
b052f52afd
|
@ -80,7 +80,6 @@ Index by Category
|
||||||
S 256 Docstring Processing System Framework Goodger
|
S 256 Docstring Processing System Framework Goodger
|
||||||
S 258 Docutils Design Specification Goodger
|
S 258 Docutils Design Specification Goodger
|
||||||
SD 262 Database of Installed Python Packages Kuchling
|
SD 262 Database of Installed Python Packages Kuchling
|
||||||
S 265 Sorting Dictionaries by Value Griffin
|
|
||||||
S 266 Optimizing Global Variable/Attribute Access Montanaro
|
S 266 Optimizing Global Variable/Attribute Access Montanaro
|
||||||
S 267 Optimized Access to Module Namespaces Hylton
|
S 267 Optimized Access to Module Namespaces Hylton
|
||||||
S 268 Extended HTTP functionality and WebDAV Stein
|
S 268 Extended HTTP functionality and WebDAV Stein
|
||||||
|
@ -200,6 +199,7 @@ Index by Category
|
||||||
SR 242 Numeric Kinds Dubois
|
SR 242 Numeric Kinds Dubois
|
||||||
SR 244 The `directive' Statement von Loewis
|
SR 244 The `directive' Statement von Loewis
|
||||||
SR 259 Omit printing newline after newline GvR
|
SR 259 Omit printing newline after newline GvR
|
||||||
|
SR 265 Sorting Dictionaries by Value Griffin
|
||||||
SD 269 Pgen Module for Python Riehl
|
SD 269 Pgen Module for Python Riehl
|
||||||
SR 270 uniq method for list objects Petrone
|
SR 270 uniq method for list objects Petrone
|
||||||
SR 271 Prefixing sys.path by command line option Giacometti
|
SR 271 Prefixing sys.path by command line option Giacometti
|
||||||
|
@ -307,7 +307,7 @@ Numerical Index
|
||||||
SD 262 Database of Installed Python Packages Kuchling
|
SD 262 Database of Installed Python Packages Kuchling
|
||||||
SF 263 Defining Python Source Code Encodings Lemburg
|
SF 263 Defining Python Source Code Encodings Lemburg
|
||||||
SF 264 Future statements in simulated shells Hudson
|
SF 264 Future statements in simulated shells Hudson
|
||||||
S 265 Sorting Dictionaries by Value Griffin
|
SR 265 Sorting Dictionaries by Value Griffin
|
||||||
S 266 Optimizing Global Variable/Attribute Access Montanaro
|
S 266 Optimizing Global Variable/Attribute Access Montanaro
|
||||||
S 267 Optimized Access to Module Namespaces Hylton
|
S 267 Optimized Access to Module Namespaces Hylton
|
||||||
S 268 Extended HTTP functionality and WebDAV Stein
|
S 268 Extended HTTP functionality and WebDAV Stein
|
||||||
|
|
21
pep-0265.txt
21
pep-0265.txt
|
@ -2,7 +2,7 @@ PEP: 265
|
||||||
Title: Sorting Dictionaries by Value
|
Title: Sorting Dictionaries by Value
|
||||||
Version: $Revision$
|
Version: $Revision$
|
||||||
Author: g2@iowegian.com (Grant Griffin)
|
Author: g2@iowegian.com (Grant Griffin)
|
||||||
Status: Draft
|
Status: Rejected
|
||||||
Type: Standards Track
|
Type: Standards Track
|
||||||
Created: 8-Aug-2001
|
Created: 8-Aug-2001
|
||||||
Python-Version: 2.2
|
Python-Version: 2.2
|
||||||
|
@ -17,6 +17,25 @@ Abstract
|
||||||
both difficult for beginners to understand and cumbersome for all
|
both difficult for beginners to understand and cumbersome for all
|
||||||
to implement.
|
to implement.
|
||||||
|
|
||||||
|
BDFL Pronouncement
|
||||||
|
|
||||||
|
This PEP is rejected because the need for it has been largely
|
||||||
|
fulfilled by Py2.4's sorted() builtin function:
|
||||||
|
|
||||||
|
>>> sorted(d.iteritems(), key=itemgetter(1), reverse=True)
|
||||||
|
[('b', 23), ('d', 17), ('c', 5), ('a', 2), ('e', 1)]
|
||||||
|
|
||||||
|
or for just the keys:
|
||||||
|
|
||||||
|
sorted(d, key=d.__getitem__, reverse=True)
|
||||||
|
['b', 'd', 'c', 'a', 'e']
|
||||||
|
|
||||||
|
Also, Python 2.5's heapq.nlargest() function addresses the common use
|
||||||
|
case of finding only a few of the highest valued items:
|
||||||
|
|
||||||
|
>>> nlargest(2, d.iteritems(), itemgetter(1))
|
||||||
|
[('b', 23), ('d', 17)]
|
||||||
|
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue