pavlovevidence at gmail.com
Tue Apr 29 16:10:03 EDT 2008
On Apr 29, 9:32 am, Roy Smith <r... at panix.com> wrote:
> The reasoning goes along the lines of, "reverse in place is an expensive
> operation, so we don't want to make it too easy for people to do". At
> least that's the gist of what I got out of the argument the many times it
> has come up.
Except reversing a list in place isn't expensive at all. I assume you
meant "reverse NOT in-place".
You're pretty much right but you're missing a step. That an in-place
operation is cheaper is the main reason why reverse is destructive,
that is true. But it returns None mostly to avoid confusing the user,
who is likely to assume that the operation is non-destructive (or
forget that it isn't).
More information about the Python-list