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
Fixed #33355 -- Optimized SQLite backend connection functions. #15173
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.
Boo! 😄 But, yes, while less elegant, this makes a lot of sense.
It's straightforward. I only had a few minor comments around naming.
A few more thoughts:
- It might be worth moving all these
_sqlite_*
functions into a separate module to decruftbase.py
, maybe a privatedjango.db.backends.sqlite._functions
module? - If in a separate module, we could do
from math import ...
and remove the attribute lookup in each function for another little speed boost? - Maybe that module could also contain a
register(connection)
function so we can move all of the registration out ofbase.py
?
543dd46
to
a727ecf
Compare
Yes I will give that a try.
And that!
Yes. |
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.
A few follow on comments...
...and then, as this issue is about optimising these functions, I couldn't resist doing a more thorough review of these as they're being moved around anyway. Seems like a good opportunity to eke out some more improvements.
Aside from the comments below, could you also group the _sqlite_*_extract()
functions together, and the _sqlite_*_trunc()
, etc., etc.
c798b1d
to
a7fdac7
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.
I extracted the changes to the trunc functions with the bug fix into #15182 , which should be merged first. Then I will rebuild this PR as a new series of commits with fewer steps.
@adamchainz Could you rebase this one now that #15182 has landed? Then I'll give it another look through. |
a7fdac7
to
91e2cd7
Compare
I've rebuilt the branch as a new series of commits. I think I managed to capture everything. |
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 Adam, this looks great! 🌟
Also thanks for humouring me with looking through for little tweaks. When shifting a bunch of stuff around like this it's worth making sure we get the maximum benefit while we're in the area.
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.
@adamchainz Thanks 👍
except (ValueError, TypeError): | ||
return None | ||
if connector == '+': | ||
# typecast_timestamp returns a date or a datetime without timezone. |
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.
# typecast_timestamp returns a date or a datetime without timezone. | |
# typecast_timestamp() returns a date or a datetime without timezone. |
91e2cd7
to
d59014e
Compare
I merged |
5927599
to
60fc594
Compare
Co-Authored-By: Nick Pope <nick@nickpope.me.uk>
…ps on SQLite. Co-Authored-By: Nick Pope <nick@nickpope.me.uk>
Co-Authored-By: Nick Pope <nick@nickpope.me.uk>
60fc594
to
c27f237
Compare
c27f237
to
5f6a727
Compare
Thanks both 🥇 I reorganized commits. |
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.
Okay, looks good!
Yyyyyyeah |
ticket-33355