Calendars and recurring events

Dave Swegen dswegen at software.plasmon.com
Fri Jan 25 10:46:54 EST 2002


On Fri, Jan 25, 2002 at 04:45:27AM -0800, Emile van Sebille wrote:
> "Dave Swegen" <dswegen at software.plasmon.com> wrote in message
> news:mailman.1011954759.15321.python-list at python.org...

[stuff deleted]

> >
> > My problem is that any time I want a view of events (say a one month
> > view), the program is going to have to traverse the whole list, and
> ask
> > if that event is due to be repeated for every day in that view. For
> one
> > month that would be ~30 traversals of the list, which seems disgusting
> in
> > its innefficiency. It might be possible to mitigate it somewhat by
> > cacheing results into a second hash (using the date as the key), but
> > that only seems like a small improvement.
> >
> 
> Sooner or later, I'm assuming you'll want to fire the events.  How about
> a class that keeps an ordered list of events by next occurrence.  This
> of course would only have each event once, but if you write an getnext
> iterator that pops the next event, and a scheduler that puts it back in
> based on it's schedule, you could pass the list once putting each event
> in, then run it through getnext and scheduler over the period in
> question.

That's quite a nice idea. Add some caching to that and it might actually
make the problem bearable. Still, I can't believe that is the most efficient
way of doing it...

I'll add it to my ponder-process :)

Cheers
	Dave




More information about the Python-list mailing list