-
-
Notifications
You must be signed in to change notification settings - Fork 718
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 decide_worker
#4332
Optimize decide_worker
#4332
Commits on Dec 9, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 082055e - Browse repository at this point
Copy the full SHA 082055eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4b0f8ff - Browse repository at this point
Copy the full SHA 4b0f8ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for edb5995 - Browse repository at this point
Copy the full SHA edb5995View commit details -
Assign
ws
with result and thenreturn
Helps Cython verify that this matches the expected `return` type before `return`ing.
Configuration menu - View commit details
-
Copy full SHA for fc6a55e - Browse repository at this point
Copy the full SHA fc6a55eView commit details -
Just use a
for
-loop to extract first itemThis winds up being a bit faster than calling `first`. ```python In [1]: from tlz import first In [2]: s = {"a"} In [3]: %timeit first(s) 76 ns ± 0.17 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) In [4]: %%timeit ...: for e in s: ...: break ...: 42.4 ns ± 0.429 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) ```
Configuration menu - View commit details
-
Copy full SHA for 13a7fc2 - Browse repository at this point
Copy the full SHA 13a7fc2View commit details -
Deduplicate
decide_worker
branchesAs the case where there are idle workers and when there are not are largely the same (except with collection of workers they draw from), choose between the two collections at the beginning. Then spend the remainder of the code on the selection logic.
Configuration menu - View commit details
-
Copy full SHA for 7745b9e - Browse repository at this point
Copy the full SHA 7745b9eView commit details -
Assign
len(worker_pool)
to a variableSince we use this in a couple of cases, go ahead and assign it to a variable initially and reuse that variable afterwards.
Configuration menu - View commit details
-
Copy full SHA for 0ca489c - Browse repository at this point
Copy the full SHA 0ca489cView commit details -
As this variable refers to a `WorkerState` instance, rename it to follow the convention we have with `WorkerState` variable names.
Configuration menu - View commit details
-
Copy full SHA for a41ccbc - Browse repository at this point
Copy the full SHA a41ccbcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3d493a6 - Browse repository at this point
Copy the full SHA 3d493a6View commit details -
Assign
ws
None
andreturn
in the first caseMakes it easier for Cython to identify that this has the expected return type when checking the value returned.
Configuration menu - View commit details
-
Copy full SHA for 1f7fdad - Browse repository at this point
Copy the full SHA 1f7fdadView commit details -
Configuration menu - View commit details
-
Copy full SHA for b94310f - Browse repository at this point
Copy the full SHA b94310fView commit details