-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 has_intersection func #11378
Conversation
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.
Thanks, the change does make sense. Maybe remove the TODO there too
b18b481
to
258bf1a
Compare
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.
OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision 258bf1a of this pull request into gerrit so we can run tests and reviews and stuff
New Gerrit review created for change 258bf1a: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/5321 |
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/5321 has been merged. Congratulations! :) |
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/5323 has been merged. Congratulations! :) |
<!-- Provide a general summary of your proposed changes in the Title field above --> Optimize `has_intersection` function. It uses in few places, but even so it might be optimized. New version: 1. Does not allocate new set 2. A bit of performance speedup ``` from sqlalchemy import util import timeit import functools a = {1, 2, 3} b = [2, 3, 4] t1 = timeit.Timer(functools.partial(util.has_intersection, a, b)) t2 = timeit.Timer(functools.partial(util.has_intersection2, a, b)) print("old", t1.timeit()) print("new", t2.timeit()) old 0.37196154199773446 new 0.29704541599494405 old 0.37331208398973104 new 0.29647241700149607 ``` ### Description <!-- Describe your changes in detail --> ### Checklist <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [x] A documentation / typographical / small typing error fix - Good to go, no issue or tests are needed - [ ] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Closes: #11378 Pull-request: #11378 Pull-request-sha: 258bf1a Change-Id: Ic1ec1448641304eba4751f55f1e3c2b217f7f352 (cherry picked from commit 5b43687)
Optimize
has_intersection
function. It uses in few places, but even so it might be optimized. New version:Description
Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>
in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>
in the commit messageHave a nice day!