3 ms·
If you're doing a lot of # crunching, you might try using Cython for those bits. You can get a 10x speedup without changing semantics and just annotating types.
by true_religion 13y ago
If you're doing a lot of # crunching, you might try using Cython for those bits. You can get a 10x speedup without changing semantics and just annotating types.
- mixmastamyk 13y agoThanks for the tip. Most of it is done by python-dateutil though so I think it in C already. I'm basically checking ~500 recurring events to see if they occur today with django-schedule.
- aidos 13y agoOooow. Interesting one. So the events can be on different schedules / frequencies? It sounds like something you should be able to do with a single sql query. Could you provide a bit more info?
- mixmastamyk 13y agoHmm, currently it uses python-dateutil to find recurring dates. I chose django-schedule at the time as it seemed the best choice, which is built upon it. I'm not certain postgres for example has that kind of functionality around dates. Googling, I found this though: http://justatheory.com/computers/databases/postgresql/recurring_events.html Looks promising. Rewriting the core of the app is a pretty big project though, it's just a side-project so I'm not sure I'll get that amount of time.
- aidos 13y agoJust thinking that maybe you had a single core lookup that you needed to optimise. A slow running "find all events that repeat on today." If it's something that's more deeply scattered through the system then it might not be worth attacking. If you just needed the events for today you should be able to do something simpler. Depends on the complexity of the frequency controls. But imagine weekly recurring - you should be able to do something like "(today - start day) mod 7 == 0" to find all weekly events that hit today. You could then construct a similar rule for each different frequency: -- not real code! select * from event where (frequency = 'daily') or (frequency = 'weekly' and (today - starts) % 7 == 0) or (frequency = 'monthly' and day(today) == day(starts)) or (frequency = ...) Just a thought.