Skip to content

Commit

Permalink
perf(core): Use chain.from_iterable in threading.py (python-zk#614)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cool-RR authored Jun 21, 2020
1 parent e4f808f commit 13c73ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kazoo/handlers/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def select(self, *args, **kwargs):
# anything to minimize changes
if _HAS_EPOLL:
# if the highest fd we've seen is > 1023
if max(map(_to_fileno, chain(*args[:3]))) > 1023:
if max(map(_to_fileno, chain.from_iterable(args[:3]))) > 1023:
return self._epoll_select(*args, **kwargs)
return self._select(*args, **kwargs)

Expand Down

0 comments on commit 13c73ec

Please sign in to comment.