Python--Faster-Way icon indicating copy to clipboard operation
Python--Faster-Way copied to clipboard

Test #2 compares different things

Open marianosimone opened this issue 11 years ago • 0 comments

while

l.sort()

works in place (modifying the original list),

sorted(l)

returns a new list.

Even when in same cases is the same using one or the other, they are doing different things.

A fair comparison would be to replace the first way with:

def a():
    l = [0, 8, 6, 4, 2, 1, 3, 5, 7, 9]
    copy = list(l)
    copy.sort()
    return copy

marianosimone avatar Jan 03 '15 00:01 marianosimone