summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRam Rachum <ram@rachum.com>2020-06-21 12:54:07 +0300
committerGitHub <noreply@github.com>2020-06-21 11:54:07 +0200
commit13c73ec5f4d4f2215deb987a059051bb821674ca (patch)
tree819043717771155f61dca9e326bdc3d99706cad2
parente4f808f7f0fe17e7e01468a2c54684f048e12b52 (diff)
downloadkazoo-13c73ec5f4d4f2215deb987a059051bb821674ca.tar.gz
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.
-rw-r--r--kazoo/handlers/threading.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/kazoo/handlers/threading.py b/kazoo/handlers/threading.py
index 1ab3349..2192523 100644
--- a/kazoo/handlers/threading.py
+++ b/kazoo/handlers/threading.py
@@ -178,7 +178,7 @@ class SequentialThreadingHandler(object):
# 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)