From f4a6dc5acabe5fbeb5ece5310f0d5c9202fcce7b Mon Sep 17 00:00:00 2001 From: Jack Zhang Date: Wed, 17 Mar 2021 13:24:38 +0800 Subject: [PATCH] pick deque instead of list --- rest_framework/throttling.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index 0ba2ba66b..1374d4492 100644 --- a/rest_framework/throttling.py +++ b/rest_framework/throttling.py @@ -2,6 +2,7 @@ Provides various throttling policies. """ import time +from collections import deque from django.core.cache import cache as default_cache from django.core.exceptions import ImproperlyConfigured @@ -120,7 +121,7 @@ class SimpleRateThrottle(BaseThrottle): if self.key is None: return True - self.history = self.cache.get(self.key, []) + self.history = self.cache.get(self.key, deque()) self.now = self.timer() # Drop any requests from the history which have now passed the