Implement ipython repr methods on Group to prevent expensive lookups
Zarr version
2.16.1
Numcodecs version
...
Python Version
...
Operating System
...
Installation
conda
Description
ipython will look for 11 custom repr methods (https://ipython.readthedocs.io/en/stable/config/integrating.html#custom-methods) in a zarr group.
Zarr chooses to map any hasattr query to a __getitem__ call so sach of these queries becomes a __getitem__ call for (e.g.) _repr_mimebundle_.array.json and _repr_mimebundle_.array.json and is interleaved with a request for _ipython_canary_method_should_not_exist_.[array|group].json.
I count 44 useless requests for a simple zarr.open_group.
I think a good solution would be to implement _ipython_display_ or _repr_mimebundle_.
It would also be nice to raise AttributeError for _ipython_canary_method_should_not_exist_.
xref https://github.com/jupyter/notebook/issues/2014
Steps to reproduce
- Create a zarr group
- Open it with some way of recording getitem requests.
Additional output
No response
Zarr chooses to map any hasattr query to a getitem call
I'm not a fan of this behavior!