-
Notifications
You must be signed in to change notification settings - Fork 495
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
rrule.between is quite slow #654
Comments
@jelly Yes, I'm very interested in performance enhancements to There are definitely some easy ones to be had with simple rules like I think it requires some careful thinking, unfortunately, so it's probably not a quick job. In the meantime, I'm not sure about your specific requirements or where these
Hopefully this helps, and if you'd like to dig deeper into this and think there are some easy performance wins that don't significantly impact code clarity or the public API, please do make a PR (or just point them out in this issue so that anyone who wants to make a PR will benefit from your work). Thanks for your report, good luck! |
what about using something like cython, to get these tight loops potentially much faster, for any pattern..? |
@srepmub A compiled backend may help, but in some ways that's beside the point. Because of the way |
sure, you could just optimize a few simple cases, but I think you may be underestimating the potential speedup of using cython or a manually written extension module (which I would guess to be something like a factor of 10 to 100 in this case). it seems natural to me for a much-used, library like dateutil to not do its core calculations in pure python.. |
@srepmub I am not underestimating it at all, and in fact have plans for a compiled backend. It's not an amazingly simple undertaking because Additionally, I am hoping to write the backend in Rust rather than C, but the bindings between Rust and the CPython API don't expose the None of this is something that you can just slap on to an existing project without some serious potential compatibility problems, and also it's irrelevant to the problem that causes |
okay, sorry, guess I misinterpreted you saying 'it may help', as english is not my first language.. :) in any case, great to hear you are working on a compiled backend! |
I'm not sure of the implications but wouldn't it be better to use an iterator instead of a list? |
The following snippet takes ~ almost 0.1 seconds to run, this seems to be due to dateutil iterating over all the dates from 2000 till 2020. There may be an possibility to not loop over all the days, speeding the calculation up but only for this simple case I guess. For example starting at the between startdate, but this doesn't seem easy to implement or would have to be special cased for 'easy' recurrences. Thoughts?
Tested on:
Dateutil 2.7.0
Python 3.6.4
Background
Our application might need to create ~ 3/4 rrule objects per request which would take up a considerable amount of time.
The text was updated successfully, but these errors were encountered: