Skip to content

Commit d4ddc17

Browse files
committed
Replacing usage of reduce in the boolean return types with python's built-in 'all' function for better performance and improved readability.
1 parent 3110e57 commit d4ddc17

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

redis/asyncio/sentinel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import random
33
import weakref
4-
from functools import reduce
54
from typing import AsyncIterator, Iterable, Mapping, Optional, Sequence, Tuple, Type
65

76
from redis.asyncio.client import Redis
@@ -248,7 +247,7 @@ async def execute_command(self, *args, **kwargs):
248247
if return_responses:
249248
return responses
250249

251-
return bool(reduce(lambda x, y: x and y, responses))
250+
return all(responses)
252251

253252
def __repr__(self):
254253
sentinel_addresses = []

redis/sentinel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import random
22
import weakref
3-
from functools import reduce
43
from typing import Optional
54

65
from redis.client import Redis
@@ -275,7 +274,7 @@ def execute_command(self, *args, **kwargs):
275274
if return_responses:
276275
return responses
277276

278-
return bool(reduce(lambda x, y: x and y, responses))
277+
return all(responses)
279278

280279
def __repr__(self):
281280
sentinel_addresses = []

0 commit comments

Comments
 (0)