intspan /

Filename Size Date modified Message
docs
intspan
test
20 B
1.4.1 rc
104 B
Ready for publish
170 B
Testing for latest pypy
660 B
Added tag 1.5.10 for changeset 254c913b84e7
219 B
updating testing
3.9 KB
Add pyproject.toml for PEP 508 conformance
11.3 KB
improving packaging completeness
156 B
repackaged
2.9 KB
tweaks
51 B
Add pyproject.toml for PEP 508 conformance
33 B
initial commit; already working
1.8 KB
Add pyproject.toml for PEP 508 conformance
149 B
updated testing
606 B
updating testing
PyPI Package latest release

intspan is a set subclass that conveniently represents sets of integers. Sets can be created from, and displayedm as integer spans such as 1-3,14,29,92-97 rather than exhaustive member listings. Compare:

intspan('1-3,14,29,92-97')
[1, 2, 3, 14, 29, 92, 93, 94, 95, 96, 97]

Or worse, the unsorted, non-intuitive listings that crop up with Python's native unordered sets, such as:

set([96, 1, 2, 3, 97, 14, 93, 92, 29, 94, 95])

While they all indicate the same values, intspan output is much more compact and comprehensible. It better divulges the contiguous nature of segments of the collection, making it easier for humans to quickly determine the "shape" of the data and ascertain "what's missing?"

When iterating, pop()-ing an item, or converting to a list, intspan behaves as if it were an ordered--in fact, sorted--collection. A key implication is that, regardless of the order in which items are added, an intspan will always be rendered in the most compact, organized form possible.

The main draw is having a convenient way to specify, manage, and see output in terms of ranges--for example, rows to process in a spreadsheet. It can also help you quickly identify or report which items were not successfully processed in a large dataset.

The main draw is having a convenient way to specify, manage, and see output in terms of ranges--for example, rows to process in a spreadsheet. It can also help you quickly identify or report which items were not successfully processed in a large dataset.

There is also an ordered intspanlist type that helps specify the ordering of a set of elements.

See the full details on Read the Docs.