-
-
Notifications
You must be signed in to change notification settings - Fork 750
Check nbytes and types before reading data
#3628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check nbytes and types before reading data
#3628
Conversation
To avoid reading `data` when it is not needed, try checking `nbytes` and `types` beforehand. If the metadata is already there, continue on without reading `data`. Otherwise fallback to the reading `data`, but do make sure to cache the results of that read to avoid doing it again.
| value = self.data[key] | ||
| except KeyError: | ||
| value = self.actors[key] | ||
| nbytes = self.nbytes[key] or sizeof(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appeared to just use getitem on nbytes, which AFAICT is a dict. So maybe getting value is never needed? If it is, maybe we should be changing this to .get(...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good catch. I don't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and used .get(...) instead and raised issue ( #3629 ) to determine whether the fallback to get value is needed.
If it is needed, this should fix a bug. If not, we can go back and remove it separately 🙂
|
+1 from me. Thanks @jakirkham |
|
Thanks for the guidance Matt 😄 |
|
Not sure I did anything, but I'll take all the credit I can get :)
…On Mon, Mar 23, 2020 at 5:05 PM jakirkham ***@***.***> wrote:
Thanks for the guidance Matt 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3628 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKZTAW45IG3AFEXIAHZHDRI72ONANCNFSM4LSH7FRQ>
.
|
Appears GitHub CI failed to checkout the code and clicking restart in the UI does not work. So pushing a dummy commit to restart it.
pentschev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a very sneaky piece of code, nice catch @jakirkham !
madsbk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Thanks everyone for the reviews and @jakirkham for the work. Merging in |
To avoid reading
datawhen it is not needed, try checkingnbytesandtypesbeforehand. If the metadata is already there, continue on without readingdata. Otherwise fallback to the readingdata, but do make sure to cache the results of that read to avoid doing it again.cc @madsbk @mrocklin