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…
More Related Contents:
- Creating an empty list in Python
- What does += mean in this context?
- Most efficient way to build single-element list from string with or without spaces? [closed]
- Unable to use convert strings into integers for a for loop
- User input integer list [duplicate]
- How to split a string into a list of characters?
- Split a string by a delimiter in python
- How to convert list to string [duplicate]
- Python Sets vs Lists
- How would you make a comma-separated string from a list of strings?
- Converting a String to a List of Words?
- How do I check if there are duplicates in a flat list?
- [] and {} vs list() and dict(), which is better?
- How do I convert a list into a string with spaces in Python?
- Why is tuple faster than list in Python?
- Perform a string operation for every element in a Python list
- How do I serialize a Python dictionary into a string, and then back to a dictionary?
- How to convert a string of space- and comma- separated numbers into a list of int? [duplicate]
- Change a string of integers separated by spaces to a list of int
- How to convert a string list into an integer in python [duplicate]
- Convert list of strings to dictionary
- Most efficient way for a lookup/search in a huge list (python)
- Sort list of strings by a part of the string
- How to create a list with the characters of a string? [duplicate]
- Python: How to check a string for substrings from a list? [duplicate]
- Create random list of integers in Python
- Get difference between two lists with Unique Entries
- split string in python to get one value?
- How can I convert string values from a dictionary, into int/float datatypes?
- deque.popleft() and list.pop(0). Is there performance difference?