Skip to content

Commit 13c73ec

Browse files
authored
perf(core): Use chain.from_iterable in threading.py (#614)
This is a faster and more idiomatic way of using itertools.chain. Instead of computing all the items in the iterable and storing them in memory, they are computed one-by-one and never stored as a huge list. This can save on both runtime and memory space.
1 parent e4f808f commit 13c73ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kazoo/handlers/threading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def select(self, *args, **kwargs):
178178
# anything to minimize changes
179179
if _HAS_EPOLL:
180180
# if the highest fd we've seen is > 1023
181-
if max(map(_to_fileno, chain(*args[:3]))) > 1023:
181+
if max(map(_to_fileno, chain.from_iterable(args[:3]))) > 1023:
182182
return self._epoll_select(*args, **kwargs)
183183
return self._select(*args, **kwargs)
184184

0 commit comments

Comments
 (0)