Skip to content

Commit df1de04

Browse files
committed
Explain Python 2/3 BytesIO behavior and data prep [ci skip]
1 parent 67d22ee commit df1de04

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

numcodecs/gzip.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ def decode(self, buf, out=None):
5151

5252
# normalise inputs
5353
if PY2: # pragma: py3 no cover
54+
# On Python 2, BytesIO always copies.
55+
# Merely ensure the data supports the (new) buffer protocol.
5456
buf = ensure_contiguous_ndarray(buf)
5557
else: # pragma: py2 no cover
58+
# BytesIO only copies if the data is not of `bytes` type.
59+
# This allows `bytes` objects to pass through without copying.
5660
buf = ensure_bytes(buf)
5761

5862
# do decompression

0 commit comments

Comments
 (0)