A suggestion for a possible Python module

Terry Reedy tjreedy at udel.edu
Tue Mar 4 15:18:41 CET 2003


"Alex Martelli" <aleax at aleax.it> wrote in message
news:nKZ8a.2029$zo2.77091 at news2.tin.it...
> Still, I do think Gries' algorithm would be a good reason to add
> optional start and stop arguments to Python lists' *reverse*
> method.  Hmmm...

I agree and have considered making the same suggestion.  There are
other good algorithms that need general subsequence/slice reversal.
Also, the almost limiting case of reversing two items,
list.reverse(k,k+2) (interpreting start,stop as slice coords) would
provide a quick and concise means of swapping adjacent list elements,
which might be the most common use of such an addition.

I have the impression from what others have posted on the internals of
function calls that adding optional arguments would make default calls
slightly slower.  However, grepping C:\python22\lib nonrecursively for
'reverse(' gives only 8 proper hits, so I do not think this is much to
worry about.

Does something as small as this need a PEP or would a feature request
(aliased as bug report) or patch (obviously better, but I can't make
one yet) be more appropriate?

Terry J. Reedy






More information about the Python-list mailing list