def __init__(self, cutoff=30 * 60): def temperature_invariant(data): data.sort(key=lambda x: x["time"]) now = int(time.time()) return [item for item in data if item["time"] >= now - cutoff] InvariantContainer.__init__(self, guarantee_invariant=temperature_invariant)