interval Module

This is the web page for information on the interval module. The interval module is a pure Python module that provides the Interval, IntervalSet, and FrozenIntervalSet classes. It runs under Python 2.4 and later.

An Interval is an abstraction for a continuous range of values. Some examples of intervals are "all values between 2 and 6," "all values less than 0," and "all values not equal to 'Bob'."

An IntervalSet is like the built-in Python set type, only it is an abstraction for a set of ranges and discrete values rather than just a set of discrete values. Another difference is that unlike sets, that can contain any hashable value, IntervalSet values must be hashable and comparable as well (__hash__ and __cmp__ must be implemented).

An IntervalSet containing the discrete values 2, 4, 6 and all values less than 0 is constructed as follows:

>>> IntervalSet([2, 4, 6, Interval.less_than(0)])

All of the same operations for sets apply to the resulting IntervalSet.

FrozenIntervalSet objects are to IntervalSet objects as frozenset objects are to set objects; FrozenIntervalSets are immutable, and IntervalSets aren't. Just like in sets and frozensets, some operations are supported in IntervalSet objects that aren't in FrozenIntervalSet objects, and vice versa.

If you have any feedback for this package, email me at jacob.h.page@gmail.com.

Installation

The interval module was packaged using the excellent distutils, so installation is a snap. After extracting the archive, from the command line, type "python setup.py install" while in the newly-extracted interval directory.

Python 2.3 Version

Micky Latowicki has contributed a version of the interval module that works with Python 2.3. To download it, click here.

Releases

1.0.0

[Change Log] [Documentation] [Bzip2 Tarball] [Zip File]

0.2.2 (alpha)

[Change Log] [Documentation] [Bzip2 Tarball] [Zip File] [Set Equivalency Test]

0.2.1 (alpha)

[Change Log] [Documentation] [Bzip2 Tarball] [Zip File]

0.2.0 (alpha)

[Change Log] [Documentation] [Bzip2 Tarball] [Zip File]

0.1 (alpha)

[Documentation] [Bzip2 Tarball] [Zip File]