pull_requests: 547053939
This data as json
id | node_id | number | state | locked | title | user | body | created_at | updated_at | closed_at | merged_at | merge_commit_sha | assignee | milestone | draft | head | base | author_association | auto_merge | repo | url | merged_by |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
547053939 | MDExOlB1bGxSZXF1ZXN0NTQ3MDUzOTM5 | 4744 | closed | 0 | Speed up Dataset._construct_dataarray | 2448579 | <!-- Feel free to remove check-list items aren't relevant to your change --> - [ ] Tests added - [x] Passes `isort . && black . && mypy . && flake8` - [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst` Significantly speeds up `_construct_dataarray` by iterating over `._coord_names` instead of `.coords`. This avoids unnecessarily constructing a `DatasetCoordinates` object and massively speeds up repr construction for datasets with large numbers of variables. Construct a 2000 variable dataset ```python import numpy as np import xarray as xr a = np.arange(0, 2000) b = np.core.defchararray.add("long_variable_name", a.astype(str)) coords = dict(time=np.array([0, 1])) data_vars = dict() for v in b: data_vars[v] = xr.DataArray( name=v, data=np.array([3, 4]), dims=["time"], coords=coords ) ds0 = xr.Dataset(data_vars) ``` Before: ``` %timeit ds0['long_variable_name1999'] %timeit ds0.__repr__() 1.33 ms ± 23 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) 2.66 s ± 52.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) ``` After: ``` %timeit ds0['long_variable_name1999'] %timeit ds0.__repr__() 10.5 µs ± 203 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) 84.2 ms ± 1.28 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) ``` | 2020-12-30T19:03:05Z | 2021-01-05T17:32:16Z | 2021-01-05T17:32:13Z | 2021-01-05T17:32:13Z | 9fefefbb564ec7a90f4f99d89352463ab81125fb | 0 | fb48be973350c66c2bd1e48b3f8df8d9faad0524 | bf0fe2caca1d2ebc4f1298f019758baa12f68b94 | MEMBER | 13221727 | https://github.com/pydata/xarray/pull/4744 |
Links from other tables
- 1 row from pull_requests_id in labels_pull_requests