An object that returns exactly nbytes when inspected by dask.sizeof.sizeof
| 695 | |
| 696 | |
| 697 | class SizeOf: |
| 698 | """ |
| 699 | An object that returns exactly nbytes when inspected by dask.sizeof.sizeof |
| 700 | """ |
| 701 | |
| 702 | def __init__(self, nbytes: int) -> None: |
| 703 | if not isinstance(nbytes, int): |
| 704 | raise TypeError(f"Expected integer for nbytes but got {type(nbytes)}") |
| 705 | if nbytes < _size_obj: |
| 706 | raise ValueError( |
| 707 | f"Expected a value larger than {_size_obj} integer but got {nbytes}." |
| 708 | ) |
| 709 | self._nbytes = nbytes - _size_obj |
| 710 | |
| 711 | def __sizeof__(self) -> int: |
| 712 | return self._nbytes |
| 713 | |
| 714 | |
| 715 | def test_sizeof(): |
no outgoing calls
searching dependent graphs…