html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/3514#issuecomment-553834279,https://api.github.com/repos/pydata/xarray/issues/3514,553834279,MDEyOklzc3VlQ29tbWVudDU1MzgzNDI3OQ==,6213168,2019-11-14T10:52:13Z,2019-11-14T10:52:13Z,MEMBER,"```python %%prun -s cumulative for _ in range(10000): ds.isel(x=[0]) ``` Output (uncached): ``` ncalls tottime percall cumtime percall filename:lineno(function) 10000 0.148 0.000 3.317 0.000 dataset.py:1854(isel) [...] 60000 0.092 0.000 0.122 0.000 indexing.py:535(shape) ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870 https://github.com/pydata/xarray/issues/3514#issuecomment-553832745,https://api.github.com/repos/pydata/xarray/issues/3514,553832745,MDEyOklzc3VlQ29tbWVudDU1MzgzMjc0NQ==,6213168,2019-11-14T10:47:43Z,2019-11-14T10:47:43Z,MEMBER,"I prefer ``pandas.utils.cache_readonly`` to the Python 3.8 ``cachedproperty``. Besides not needing a dict, it is also written in cython, which should make a substantial difference. max-sixty could you post your benchmark where you measure 150us? I tried caching that property with @cache_readonly and I only get a boost of 7us. ```python import xarray ds = xarray.Dataset({'d': ('x', [1, 2]), 'x': [10, 20]}) ds ds.to_netcdf(""foo.nc"") ds.close() ds = xarray.open_dataset(""foo.nc"") %timeit ds.isel(x=[0]) ``` With ``@property``: 187us With ``@cache_readonly``: 180us","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870 https://github.com/pydata/xarray/issues/3514#issuecomment-553815808,https://api.github.com/repos/pydata/xarray/issues/3514,553815808,MDEyOklzc3VlQ29tbWVudDU1MzgxNTgwOA==,6213168,2019-11-14T10:02:57Z,2019-11-14T10:02:57Z,MEMBER,@max-sixty afraid so. But as I said it should be straightforward to use a variant that instead of ``self.__dict__[self.name]`` uses getattr/setattr.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870 https://github.com/pydata/xarray/issues/3514#issuecomment-553573320,https://api.github.com/repos/pydata/xarray/issues/3514,553573320,MDEyOklzc3VlQ29tbWVudDU1MzU3MzMyMA==,5635139,2019-11-13T19:52:18Z,2019-11-13T19:52:18Z,MEMBER,"> By reading the implementation of cachedproperty, it needs a `__dict__`. It should be straightforward to write a variant that uses slots though. Is there a way of doing that which doesn't nullify the benefits of slots? i.e. if we add a `_cache_dict` to the class, is that the same overhead as having a `__dict__`?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870 https://github.com/pydata/xarray/issues/3514#issuecomment-553100094,https://api.github.com/repos/pydata/xarray/issues/3514,553100094,MDEyOklzc3VlQ29tbWVudDU1MzEwMDA5NA==,6213168,2019-11-12T20:28:45Z,2019-11-12T20:28:45Z,MEMBER,"By reading the implementation of cachedproperty, it needs a ``__dict__``. It should be straightforward to write a variant that uses slots though. ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870 https://github.com/pydata/xarray/issues/3514#issuecomment-553093801,https://api.github.com/repos/pydata/xarray/issues/3514,553093801,MDEyOklzc3VlQ29tbWVudDU1MzA5MzgwMQ==,5635139,2019-11-12T20:11:22Z,2019-11-12T20:11:35Z,MEMBER,"Great, I didn't know about that, thanks It does remind me, though, that I'm not sure it's possible given we're using `__slots__`, at least without adding an entry to `__slots__`... https://github.com/python/cpython/blob/d360346640e19231032b072216195484fa2450b4/Lib/functools.py#L954-L958 ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870 https://github.com/pydata/xarray/issues/3514#issuecomment-553079425,https://api.github.com/repos/pydata/xarray/issues/3514,553079425,MDEyOklzc3VlQ29tbWVudDU1MzA3OTQyNQ==,1217238,2019-11-12T19:36:35Z,2019-11-12T19:36:35Z,MEMBER,"I think this would be totally fine to add. A variant on `cache_readonly` appears in Python 3.8 standard library as `functools.cached_property`. I think we could backport that pretty easily: https://github.com/python/cpython/blob/d360346640e19231032b072216195484fa2450b4/Lib/functools.py#L924","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,521754870