Skip to content

Commit 353c9b8

Browse files
committed
Avoid instantiating entire dataset by getting the nbytes in an array
Using `.data` accidentally tries to load the whole lazy arrays into memory. Sad.
1 parent ed60c6c commit 353c9b8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

xarray/core/variable.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,10 @@ def nbytes(self) -> int:
403403
If the underlying data array does not include ``nbytes``, estimates
404404
the bytes consumed based on the ``size`` and ``dtype``.
405405
"""
406-
if hasattr(self.data, "nbytes"):
407-
return self.data.nbytes
406+
import pdb; pdb.set_trace()
407+
if hasattr(self._data, "nbytes"):
408+
print("can do")
409+
return self._data.nbytes
408410
else:
409411
return self.size * self.dtype.itemsize
410412

0 commit comments

Comments
 (0)