Message196573
The two cases are not parallel.
a = sorted(b)
abbreviates
a = list(b)
a.sorted()
which occurred often enough to be a nuisance. With this proposal,
a = reversed(b)
would abbreviate
a = reversed(list(b))
which is probably less common and certainly less obnoxious than the two lines condensed by sorted.
A second problem: reversed already has a fallback default if (a presumably more efficient or effective) b.__reversed__ does not exit:
n = len(b)
a = [None]*n
for i,j in enumerate(range(n-1, -1, -1)): # reversed(range(n))
a[i] = b[j]
(I believe this is more efficient, at least in C, than
a = []
for i in range(len(b)-1, -1, -1):
a.append(b[i])
but it is hard to know.)
At what point, and under what conditions, would you introduce the second fallback? |
|
Date |
User |
Action |
Args |
2013-08-30 20:52:25 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, dstufft, madison.may |
2013-08-30 20:52:25 | terry.reedy | set | messageid: <1377895945.31.0.366216635706.issue18826@psf.upfronthosting.co.za> |
2013-08-30 20:52:25 | terry.reedy | link | issue18826 messages |
2013-08-30 20:52:24 | terry.reedy | create | |
|