Skip to content

Commit 79ad8e2

Browse files
committed
Add link about Python 2 GZip workaround [ci skip]
Lest we or others wonder what this workaround is doing. Link back to the PR comment for details. TL;DR - GZip on Python 2 (and Python pre-3.5) determines the number of bytes included via `len`, which is needed for the GZip footer. This will be incorrect if the data is not flattened and using a single byte type. Hence we cast to `uint8` here to satisfy this constraint. On Python 3.5+ this is not needed as it casts the data to a `memoryview` and accesses the `nbytes` attribute to determine this. ref: #128 (comment)
1 parent df60e2f commit 79ad8e2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

numcodecs/gzip.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def encode(self, buf):
2929
buf = ensure_contiguous_ndarray(buf)
3030
if PY2: # pragma: py3 no cover
3131
# view as u1 needed on PY2
32+
# ref: https://github.com/zarr-developers/numcodecs/pull/128#discussion_r236786466
3233
buf = buf.view('u1')
3334

3435
# do compression

0 commit comments

Comments
 (0)