Using Infinities with Generators

Python infinities are useful for checking minimal and maximal values when the values arrive incrementally from streams, loops, or generators, e.g.:

min_value = float("inf")
max_value = float("-inf")

for value in read_response_time_stream():
    min_value = min(min_value, value)
    max_value = max(max_value, value)

Tips and Tricks Programming Python 3