Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ def __setitem__(self, key, value):
else:
keyinfo.external_attr = 0o644 << 16 # ?rw-r--r--

self.zf.writestr(keyinfo, value)
self.zf.writestr(keyinfo, value.tobytes())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would introduce an additional copy before writing to disk.

Guessing the issue is ZipFile assumes data here is uint8 even if that may not be the case. Also suspect this only happens when a compressor is not used (otherwise this would already be the case)

Would suggest changing line 1554 above to add .view("u1") to cast to uint8. This should have the same end result (data is represented as uint8), but not cause a copy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll write a test case as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is added now.


def __delitem__(self, key):
raise NotImplementedError
Expand Down