Ensure we check leap seconds only when Time is actually used.#9491
Merged
mhvk merged 1 commit intoastropy:masterfrom Oct 28, 2019
Merged
Ensure we check leap seconds only when Time is actually used.#9491mhvk merged 1 commit intoastropy:masterfrom
mhvk merged 1 commit intoastropy:masterfrom
Conversation
taldcroft
reviewed
Oct 27, 2019
| # Because of import problems, this can only be done on | ||
| # first call of Time. | ||
| global _LEAP_SECONDS_CHECKED | ||
| if not _LEAP_SECONDS_CHECKED: |
Member
There was a problem hiding this comment.
Maybe you could save two lines of code and a global by holding this attribute in the Time class. So
if not getattr(Time, '_LEAP_SECONDS_CHECKED', False):
Time._LEAP_SECONDS_CHECKED = True
update_leap_seconds()
But on the whole this solution seems fine. I did confirm that it resolves the problems I found.
Contributor
Author
There was a problem hiding this comment.
I thought about putting it on the class, but ended up feeling it was slightly more elegant (less inelegant?) to have it as global state,. Also perhaps slightly faster?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I went with only calling
update_leap_secondson first call ofTime. Somewhat ugly but it does work. Better suggestions most welcome...fixes #9490