Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106450 > unrolled thread

Re: Set type for datetime intervals

Started by"Martin A. Brown" <martin@linux-ip.net>
First post2016-04-04 08:46 -0700
Last post2016-04-04 08:46 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Set type for datetime intervals "Martin A. Brown" <martin@linux-ip.net> - 2016-04-04 08:46 -0700

#106450 — Re: Set type for datetime intervals

From"Martin A. Brown" <martin@linux-ip.net>
Date2016-04-04 08:46 -0700
SubjectRe: Set type for datetime intervals
Message-ID<mailman.25.1459784816.32530.python-list@python.org>
Greetings László,

>I need to compare sets of datetime intervals, and make set 
>operations on them: intersect, union, difference etc. One element 
>of a set would be an interval like this:
>
>element ::= (start_point_in_time, end_point_in_time)
>intervalset ::= { element1, element2, .... }
>
>Operations on elements:
>
>element1.intersect(element2)
>element1.union(element2)
>element1.minus(element2)
>
>Operations on sets:
>
>intervalset1.intersect(intervalset2)
>intervalset1.union(intervalset2)
>intervalset1.minus(intervalset2)
>
>Does anyone know a library that already implements these functions?

Sorry to be late to the party--I applaud that you have already 
crafted something to attack your problem.  When you first posted, 
there was a library that was tickling my memory, but I could not 
remember its (simple) name.  It occurred to me this morning, after 
you posted your new library:

  https://pypi.python.org/pypi/intervaltree

This handles overlapping ranges nicely and provides some tools for 
managing them.  Before posting this, I checked that it works with 
datetime types, and, unsurprisingly, it does.

Happy trails!

-Martin

-- 
Martin A. Brown
http://linux-ip.net/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web