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/1121#issuecomment-260704684,https://api.github.com/repos/pydata/xarray/issues/1121,260704684,MDEyOklzc3VlQ29tbWVudDI2MDcwNDY4NA==,1310437,2016-11-15T17:15:25Z,2016-11-15T17:15:25Z,CONTRIBUTOR,"I think I found it (#1122). I guess whenever a non-scalar assignment is made (as in `result[:] = [value]`), something like `np.asanyarray` is performed on the new value. Luckily, numpy is perfectly happy with indexing of a 0d array with a 0d index (i.e. an empty tuple). Thinking about it, `result[0] = value` would probably have worked too. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,189415576 https://github.com/pydata/xarray/issues/1121#issuecomment-260697960,https://api.github.com/repos/pydata/xarray/issues/1121,260697960,MDEyOklzc3VlQ29tbWVudDI2MDY5Nzk2MA==,1310437,2016-11-15T16:52:41Z,2016-11-15T16:52:41Z,CONTRIBUTOR,"Well, xarrays are way too useful not to nest them, even if that involves the scary `dtype=object` :-). Thanks for pointing me in the right direction, I'll try to find a fix. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,189415576 https://github.com/pydata/xarray/issues/1121#issuecomment-260683252,https://api.github.com/repos/pydata/xarray/issues/1121,260683252,MDEyOklzc3VlQ29tbWVudDI2MDY4MzI1Mg==,1217238,2016-11-15T16:05:20Z,2016-11-15T16:05:20Z,MEMBER,"Nesting xarray objects was not an intended use case, but I agree, this is ridiculously slow. Looks the culprit is `xarray.core.utils.to_0d_object_array`: https://github.com/pydata/xarray/blob/d66f673ab25fe0fc0483bd5d67479fc94a14e46d/xarray/core/utils.py#L198-L212 Specifically, when `value` is an `xarray.DataArray`, these lines appear to trigger a iterating over every element of the DataArray, one by one: ``` result = np.empty((1,), dtype=object) result[:] = [value] ``` I'm definitely open to fixes here. Creating a NumPy object array can be very fussy -- NumPy tries way too hard to coerce dtypes. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,189415576