List Comprehensions in Python to compute minimum and maximum values of a list
问题 i have the following code to compute minimum and maximum values of a list in order to save memory efficiency x_min = float('+inf') x_max = float('-inf') for p in points_in_list: x_min = min(x_min, p) x_max = max(x_max, p) where points_in_list is a (large) list of numbers. I wish to know if there is a method to compute with a List Comprehensions the min and max value and saving the memory. 回答1: I'm a big fan of generators and comprehensions, but in this case it seems they are not the right way