File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ Unreleased
2020
2121Enhancements
2222~~~~~~~~~~~~
23+ * [v3] Dramatically reduce number of ``__contains_ `` requests in favor of optimistically calling `__getitem__ `
24+ and handling any error that may arise.
25+ By :user: `Deepak Cherian <dcherian> `.
2326
2427* [v3] Reuse the download array metadata when creating an ``Array ``.
2528 By :user: `Deepak Cherian <dcherian> `.
Original file line number Diff line number Diff line change @@ -151,19 +151,20 @@ def _put_nosync(self, d):
151151 if self .cache :
152152 self ._cached_asdict = d
153153 else :
154- if self .key in self .store :
154+ try :
155+ meta_unparsed = self .store [self .key ]
155156 # Cannot write the attributes directly to JSON, but have to
156157 # store it within the pre-existing attributes key of the v3
157158 # metadata.
158159
159160 # Note: this changes the store.counter result in test_caching_on!
160161
161- meta = self .store ._metadata_class .parse_metadata (self . store [ self . key ] )
162+ meta = self .store ._metadata_class .parse_metadata (meta_unparsed )
162163 if "attributes" in meta and "filters" in meta ["attributes" ]:
163164 # need to preserve any existing "filters" attribute
164165 d ["attributes" ]["filters" ] = meta ["attributes" ]["filters" ]
165166 meta ["attributes" ] = d ["attributes" ]
166- else :
167+ except KeyError :
167168 meta = d
168169 self .store [self .key ] = json_dumps (meta )
169170 if self .cache :
You can’t perform that action at this time.
0 commit comments