Python dateutil.rrule is incredibly slow

I am using the python dateythil module for a calendar app that supports recurring events. I really like the ability to parse rules using the rrulestr () function. Also, using rrule.between () to get dates within a given interval is very fast.

However, as soon as I try to do any other operations (i.e.: list of fragments, before (), after (), ...) everything starts scanning. It seems like dateutil is trying to calculate every date, even if all I want is to get the latest date from rrule.before (datetime.max).

Is there a way to avoid this unnecessary computation?

+2


source to share


1 answer


My guess is probably not. The last date before datetime.max means you need to calculate all repetitions up to datetime.max, and that would be a reasonably high number of repetitions. It might be possible to add shortcuts for some simpler repetitions. For example, if it's on the same date every year, you don't need to, for example, calculate repetitions between them. But if you have something third that you should, for example, and if you have maximum repetitions, etc. But I guess dateutil doesn't have these shortcuts. It would probably be quite difficult to implement reliably.



May I ask why you need to find the last repetition before datetime.max? It is, after all, almost eight thousand years in the future ... :-)

+4


source