-
Notifications
You must be signed in to change notification settings - Fork 467
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
Make order of previous locales deterministic #851
Make order of previous locales deterministic #851
Conversation
Codecov Report
@@ Coverage Diff @@
## master #851 +/- ##
==========================================
+ Coverage 98.33% 98.37% +0.03%
==========================================
Files 231 231
Lines 2590 2591 +1
==========================================
+ Hits 2547 2549 +2
+ Misses 43 42 -1
Continue to review full report at Codecov.
|
I can change to use |
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.
3dfae75
to
dc0c1d4
Compare
@@ -457,7 +457,7 @@ def date_strings(): | |||
yield stripped_date_string | |||
|
|||
if self.try_previous_locales: | |||
for locale in self.previous_locales: | |||
for locale in self.previous_locales.keys(): |
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.
💄
for locale in self.previous_locales.keys(): | |
for locale in self.previous_locales: |
I’m just mentioning this in case .keys()
was not added on purpose. But given .keys()
is more explicit, maybe the current code is more readable. ✔️ either way.
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 think we can leave it as-is. For me, it seems more accurate to explicitly indicate that we iterate through the keys. 👍
Thanks again @surkova! 🚀 |
When using
set
for storing previously seen locales we eventually end up in the land of non-determinism when looping through them:Since python 3.7 insertion order is preserved in dictionaries, so we can take advantage of this.
I'm not sure what the policy is as for support of python < 3.7, on travis we seem to be running even 3.5, then my test will fail there. However, when looking at this discussion, I see there's an appetite for making this logic deterministic. Approach with
dict
should not be slowing parsing either: