From 9853655db25787b7a531e4e8df9de6d0a48f0782 Mon Sep 17 00:00:00 2001 From: Rahul Shendage Date: Sat, 5 Oct 2024 17:17:09 +0530 Subject: [PATCH] Removed unnecessary variable initialization from discard method on sorted sets We can avoid declaring _set variable and directly access self._set. For now doing this in discard method only. I can work on entire code base to remove unnecessary allocations, only in the places where this does not adversely affect the readability --- src/sortedcontainers/sortedset.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sortedcontainers/sortedset.py b/src/sortedcontainers/sortedset.py index f2416bf..66b391d 100644 --- a/src/sortedcontainers/sortedset.py +++ b/src/sortedcontainers/sortedset.py @@ -391,9 +391,8 @@ def discard(self, value): :param value: `value` to discard from sorted set """ - _set = self._set - if value in _set: - _set.remove(value) + if value in self._set: + self._set.remove(value) self._list.remove(value) _discard = discard