Thu, 30 Jul 2020 21:52:31 +0300
destination processing
from configparser import ConfigParser profile = ConfigParser() def minmax(data): ''' From: http://code.activestate.com/recipes/577916-fast-minmax-function/ Computes the minimum and maximum values in one-pass using only 1.5*len(data) comparisons ''' import itertools it = iter(data) try: lo = hi = next(it) except StopIteration: raise ValueError('minmax() arg is an empty sequence') for x, y in itertools.zip_longest(it, it, fillvalue = lo): if x > y: x, y = y, x lo = min(x, lo) hi = max(y, hi) return lo, hi