-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Optimize Array.info and Group.info #1733
Conversation
Avoid repeated computes of the same value (getsize)
Apparently IPython will run both __repr__ and _repr_html_ so we were calling `getsize` twice.
|
||
def __repr__(self): | ||
items = self.obj.info_items() | ||
return info_text_report(items) | ||
return info_text_report(self.items) |
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.
The previous version called info_items
twice per repr in a notebook.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1733 +/- ##
=======================================
Coverage 99.99% 99.99%
=======================================
Files 38 38
Lines 14611 14610 -1
=======================================
- Hits 14610 14609 -1
Misses 1 1
|
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.
@dcherian - brilliant!
Makes me wonder how many of these patterns exist in our zarr-Python today! ☠️
Co-authored-by: Joe Hamman <jhamman1@gmail.com>
* main: Couple fixes (zarr-developers#1737) Bump actions/setup-python from 5.0.0 to 5.1.0 (zarr-developers#1736) Optimize Array.info and Group.info (zarr-developers#1733) chore: update pre-commit hooks (zarr-developers#1738)
Avoid repeated computes of the same value
getsize
From 6 getsize requests to 1.
TODO: