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/7221#issuecomment-1291948502,https://api.github.com/repos/pydata/xarray/issues/7221,1291948502,IC_kwDOAMm_X85NAZHW,90008,2022-10-26T12:19:49Z,2022-10-26T12:23:46Z,CONTRIBUTOR,"I know it is not comparable, but I was really curious what ""dictionary insertion"" costs, in order to be able to understand if my comparisons were fair:
code ```python from tqdm import tqdm import xarray as xr from time import perf_counter import numpy as np N = 1000 # Everybody is lazy loading now, so lets force modules to get instantiated dummy_dataset = xr.Dataset() dummy_dataset['a'] = 1 dummy_dataset['b'] = 1 del dummy_dataset time_elapsed = np.zeros(N) # dataset = xr.Dataset() dataset = {} for i in tqdm(range(N)): # for i in range(N): time_start = perf_counter() dataset[f""var{i}""] = i time_end = perf_counter() time_elapsed[i] = time_end - time_start # %% from matplotlib import pyplot as plt plt.plot(np.arange(N), time_elapsed * 1E6, label='Time to add one variable') plt.xlabel(""Number of existing variables"") plt.ylabel(""Time to add a variables (us)"") plt.ylim([0, 10]) plt.title(""Dictionary insertion"") plt.grid(True) ```
![image](https://user-images.githubusercontent.com/90008/198024147-0965787a-32be-409b-959c-1b87adbc633a.png) I think xarray gives me 3 order of magnitude of ""thinking"" benefit, so I'll take it! ``` python --version Python 3.9.13 ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423312198 https://github.com/pydata/xarray/pull/7221#issuecomment-1291894024,https://api.github.com/repos/pydata/xarray/issues/7221,1291894024,IC_kwDOAMm_X85NAL0I,90008,2022-10-26T11:32:32Z,2022-10-26T11:32:32Z,CONTRIBUTOR,"Ok. I'll want to rethink them. I know it looks quadratic time, but i really would like to test n=1000 and i have an idea","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423312198 https://github.com/pydata/xarray/pull/7221#issuecomment-1291450556,https://api.github.com/repos/pydata/xarray/issues/7221,1291450556,IC_kwDOAMm_X85M-fi8,90008,2022-10-26T03:32:53Z,2022-10-26T03:32:53Z,CONTRIBUTOR,"I'm somewhat ocnfused, I can run the benchmark locally ``` [ 1.80%] ··· dataset_creation.Creation.time_dataset_creation 4.37±0s ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423312198 https://github.com/pydata/xarray/pull/7221#issuecomment-1291447746,https://api.github.com/repos/pydata/xarray/issues/7221,1291447746,IC_kwDOAMm_X85M-e3C,90008,2022-10-26T03:27:36Z,2022-10-26T03:27:36Z,CONTRIBUTOR,":/ not fun, the benchmark is failing. not sure why.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423312198 https://github.com/pydata/xarray/pull/7221#issuecomment-1291399714,https://api.github.com/repos/pydata/xarray/issues/7221,1291399714,IC_kwDOAMm_X85M-TIi,90008,2022-10-26T02:14:40Z,2022-10-26T02:14:40Z,CONTRIBUTOR,"> Would be interesting to see whether this was covered by our existing asv benchmarks. I wasn't able to find something that really benchmarked ""large"" datasets. > Would be a good benchmark to add if we don't have one already. Added one. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423312198 https://github.com/pydata/xarray/pull/7221#issuecomment-1291389702,https://api.github.com/repos/pydata/xarray/issues/7221,1291389702,IC_kwDOAMm_X85M-QsG,90008,2022-10-26T01:59:57Z,2022-10-26T01:59:57Z,CONTRIBUTOR,"> out of interest, how did you find this? Spyder profiler","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423312198