Skip to content

Commit

Permalink
Call x.tobytes() once and assign it
Browse files Browse the repository at this point in the history
Avoid repeated copies while testing that don't add value here.
  • Loading branch information
jakirkham committed May 6, 2022
1 parent 99a1179 commit 46c1b8f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions distributed/protocol/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ def test_compression_1():
pytest.importorskip("lz4")
np = pytest.importorskip("numpy")
x = np.ones(1000000)
frames = dumps({"x": Serialize(x.tobytes())})
assert sum(map(nbytes, frames)) < x.nbytes
b = x.tobytes()
frames = dumps({"x": Serialize(b)})
assert sum(map(nbytes, frames)) < nbytes(b)
y = loads(frames)
assert {"x": x.tobytes()} == y
assert {"x": b} == y


def test_compression_2():
Expand Down

0 comments on commit 46c1b8f

Please sign in to comment.