Exemple #1
0
    def __repr__(self):
        last_values = []
        for k in islice(self.last_used, 10):
            last_values.append((k, self.values[k]))

        return '<LRU size=%d values=%s%s>' % (
            self.size, repr(last_values)[:-1],
            ', ...]' if len(self)>10 else ']')
Exemple #2
0
def repeated_values(values, n):
    current_factor = 1
    step_factor = 10
    result = []
    for i, value in enumerate(itertools.islice(itertools.cycle(values), n)):
        if i != 0 and i % len(values) == 0:
            current_factor *= step_factor
        result.append(value/current_factor)
    return result
Exemple #3
0
def repeated_values(values, n):
    current_factor = 1
    step_factor = 10
    result = []
    for i, value in enumerate(itertools.islice(itertools.cycle(values), n)):
        if i != 0 and i % len(values) == 0:
            current_factor *= step_factor
        result.append(value / current_factor)
    return result