home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 893208691

This data as json

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/pull/5667#issuecomment-893208691 https://api.github.com/repos/pydata/xarray/issues/5667 893208691 IC_kwDOAMm_X841PUhz 14371165 2021-08-05T06:45:09Z 2021-08-05T07:07:29Z MEMBER

Some fun performance comparisons related to copying and initializing dicts:

```python a = dict(a=2, b=3)

%timeit dict(a) 207 ns ± 3.41 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

%timeit a.copy() 82.6 ns ± 0.425 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)

import copy %timeit copy.copy(a) 313 ns ± 3.59 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

from copy import copy %timeit copy(a) 290 ns ± 3.63 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

from copy import deepcopy %timeit deepcopy(a) 3.39 µs ± 55.6 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) ```

Using a.copy() seems to be the way to go if you want to do a shallow copy of a dict.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  958878760
Powered by Datasette · Queries took 0.858ms · About: xarray-datasette