From 80ea63a46ed0997ef28766c63d026d9483866d1d Mon Sep 17 00:00:00 2001 From: jakirkham Date: Fri, 31 Jul 2020 10:31:41 -0700 Subject: [PATCH] Only call `frame_split_size` when there are frames (#3996) This just becomes a no-op if an empty list is given (returning an empty list). However there is no need to do this work if we don't need it. So simply restrict calling `frame_split_size` to the case where frames are present and compression will occur. --- distributed/protocol/serialize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributed/protocol/serialize.py b/distributed/protocol/serialize.py index fb285bd1f00..8ebac2500f5 100644 --- a/distributed/protocol/serialize.py +++ b/distributed/protocol/serialize.py @@ -475,8 +475,8 @@ def serialize_bytelist(x, **kwargs): header, frames = serialize(x, **kwargs) if "lengths" not in header: header["lengths"] = tuple(map(nbytes, frames)) - frames = sum(map(frame_split_size, frames), []) if frames: + frames = sum(map(frame_split_size, frames), []) compression, frames = zip(*map(maybe_compress, frames)) else: compression = []