From 3ec8b13af74f886bdb4a421ed96bd3bd2f05ded5 Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Fri, 5 Aug 2022 02:14:27 +0530 Subject: [PATCH 1/4] Add `__slots__` to `AsyncLimiter` --- src/aiolimiter/leakybucket.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/aiolimiter/leakybucket.py b/src/aiolimiter/leakybucket.py index 4d41bec..feee5a7 100644 --- a/src/aiolimiter/leakybucket.py +++ b/src/aiolimiter/leakybucket.py @@ -29,6 +29,9 @@ class AsyncLimiter(AbstractAsyncContextManager): within this time period in a burst. """ + + __slots__ = ("max_rate", "time_period", "_rate_per_sec", "_level", + "_last_check", "_waiters") max_rate: float #: The configured `max_rate` value for this limiter. time_period: float #: The configured `time_period` value for this limiter. From 1341ac80f60d64032559deedd23fc7882bf51969 Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Sat, 6 Aug 2022 16:09:27 +0530 Subject: [PATCH 2/4] run black on file --- src/aiolimiter/leakybucket.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/aiolimiter/leakybucket.py b/src/aiolimiter/leakybucket.py index feee5a7..38152be 100644 --- a/src/aiolimiter/leakybucket.py +++ b/src/aiolimiter/leakybucket.py @@ -29,9 +29,15 @@ class AsyncLimiter(AbstractAsyncContextManager): within this time period in a burst. """ - - __slots__ = ("max_rate", "time_period", "_rate_per_sec", "_level", - "_last_check", "_waiters") + + __slots__ = ( + "max_rate", + "time_period", + "_rate_per_sec", + "_level", + "_last_check", + "_waiters", + ) max_rate: float #: The configured `max_rate` value for this limiter. time_period: float #: The configured `time_period` value for this limiter. From 60288a4508d433d8c4e0e23b926f487fe9467c27 Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Tue, 9 Aug 2022 01:20:13 +0530 Subject: [PATCH 3/4] Create 85.feature --- changelog.d/85.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/85.feature diff --git a/changelog.d/85.feature b/changelog.d/85.feature new file mode 100644 index 0000000..9b3a770 --- /dev/null +++ b/changelog.d/85.feature @@ -0,0 +1 @@ +Add ``__slots__`` to the ``AsyncLimiter`` class. From 047c74031921c64d51a399d23a8286a45ced7851 Mon Sep 17 00:00:00 2001 From: Harshil <37377066+harshil21@users.noreply.github.com> Date: Tue, 9 Aug 2022 17:09:17 +0530 Subject: [PATCH 4/4] Update changelog.d/85.feature Co-authored-by: Martijn Pieters --- changelog.d/85.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/85.feature b/changelog.d/85.feature index 9b3a770..647dd50 100644 --- a/changelog.d/85.feature +++ b/changelog.d/85.feature @@ -1 +1 @@ -Add ``__slots__`` to the ``AsyncLimiter`` class. +Add ``__slots__`` to the ``AsyncLimiter`` class, reducing memory requirements.