Length of longest word in a list

Although:

max(len(w) for w in words)

does kind of “read” easier – you’ve got the overhead of a generator.

While:

len(max(words, key=len))

can optimise away with the key using builtins and since len is normally a very efficient op for strings, is going to be faster…

Leave a Comment