Limitation of os.walk

Patrick Maupin pmaupin at gmail.com
Wed May 12 18:26:23 EDT 2010


On May 12, 2:04 pm, kj <no.em... at please.post> wrote:
> <petpeeve>It seems that a similar "simplicity argument" was invoked
> to strip the cmp option from sort in Python 3.  Grrrr.  Simplicity
> is great, but when the drive for it starts causing useful functionality
> to be thrown out, then it is going too far.  Yes, I know that it
> is possible to do everything that sort's cmp option does through
> clever tricks with key, but grokking and coding this maneuver
> requires a *lot* more Python-fu than cmp did, which makes this
> functionality a lot less accessible to beginners that the intrinsic
> complexity of the problem warrants.  And for what?  To get rid of
> an *option* that could be easily disregarded by anyone who found
> it too "complex"? It makes no sense to me.</petpeeve>

I didn't follow the discussion on cmp and Python 3, but I would assume
one reason it was removed was for performance.  cmp is very slow
compared to key, and if there should be one obvious way to do it, it
should probably be the way that runs faster.  Also, while in many
cases cmp can be easier to use than key, it would be possible for a
naive person with a complicated data structure to come up with a cmp
function that, e.g. sorted A > B, B > C, and C > A.  It's impossible
to come up with a key function that will break sort in that fashion.
So, while I understand the frustration of having a favorite tool
removed, I have no trouble believing that there were good reasons for
the removal.

Regards,
Pat



More information about the Python-list mailing list