This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Implementation of exponential rate limiter from <https://dotat.at/@/2024-09-02-ewma.html>, | |
but using a single variable `next-time` to store the state.""" | |
import time | |
import math | |
class RateLimiter: | |
def __init__(self, window, limit): | |
self.next_time = 0.0 |