A Range is an object resembling a set but optimised for contiguous
ranges of int members.
*Latest release 20230701*:
Assorted bugfixes.
## Function `overlap(span1, span2)`
Return a list `[start,end]` denoting the overlap of two spans.
Example:
>>> overlap([1,9], [5,13])
[5, 9]
## Class `Range`
A collection of `int`s that collates adjacent ints.
The interface is as for a `set` with additional methods:
* `spans()`: return an iterable of `Span`s, with `.start`
included in each `Span` and `.end` just beyond
Additionally, the update/remove/etc methods have a secondary
calling signature: `(start,end)`, which is the same as passing
in `Range(start,end)` but much more efficient.
*Method `Range.__init__(self, start=None, end=None, debug=None)`*:
Initialise the Range.
Called with `start` and `end`, these specify the initial
`Span` of the `Range`.
If called with just one argument that argument instead be an iterable
of integer values comprising the values in the `Range`.
## Class `Span(Span, builtins.tuple)`
A namedtuple with `.start` and `.end` attributes.
## Function `spans(items)`
Return an iterable of `Spans` for all contiguous sequences in
`items`.
Example:
>>> list(spans([1,2,3,7,8,11,5]))
[1:4, 7:9, 11:12, 5:6]
# Release Log
*Release 20230701*:
Assorted bugfixes.
*Release 20230619*:
* Span: sanity check .start and .end.
* Range.issubset: efficient comparison with another Range, also .issuperset.
*Release 20230518*:
Span,Range: new as_list() methods.
*Release 20190102*:
Span: provide __len__.
*Release 20171231*:
* Add Range.span0, returning the first Span.
* Implement __bool__ and__nonzero__.
* Accept a Span in __contains__.
* Some small bugfixes.
*Release 20160828*:
* Add Range.start like existing Range.end.
* Use "install_requires" instead of "requires" in DISTINFO.
* Small bugfix.
*Release 20150116*:
First PyPI release.
Raw data
{
"_id": null,
"home_page": "https://bitbucket.org/cameron_simpson/css/commits/all",
"name": "cs.range",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python2,python3",
"author": "Cameron Simpson",
"author_email": "Cameron Simpson <cs@cskk.id.au>",
"download_url": "https://files.pythonhosted.org/packages/7f/72/25c249904759e529c47aab5d3c822ce342afad46ab914c8ef18f4f1d17ac/cs.range-20230701.tar.gz",
"platform": null,
"description": "A Range is an object resembling a set but optimised for contiguous\nranges of int members.\n\n*Latest release 20230701*:\nAssorted bugfixes.\n\n## Function `overlap(span1, span2)`\n\nReturn a list `[start,end]` denoting the overlap of two spans.\n\nExample:\n\n >>> overlap([1,9], [5,13])\n [5, 9]\n\n## Class `Range`\n\nA collection of `int`s that collates adjacent ints.\n\nThe interface is as for a `set` with additional methods:\n* `spans()`: return an iterable of `Span`s, with `.start`\n included in each `Span` and `.end` just beyond\n\nAdditionally, the update/remove/etc methods have a secondary\ncalling signature: `(start,end)`, which is the same as passing\nin `Range(start,end)` but much more efficient.\n\n*Method `Range.__init__(self, start=None, end=None, debug=None)`*:\nInitialise the Range.\n\nCalled with `start` and `end`, these specify the initial\n`Span` of the `Range`.\nIf called with just one argument that argument instead be an iterable\nof integer values comprising the values in the `Range`.\n\n## Class `Span(Span, builtins.tuple)`\n\nA namedtuple with `.start` and `.end` attributes.\n\n## Function `spans(items)`\n\nReturn an iterable of `Spans` for all contiguous sequences in\n`items`.\n\nExample:\n\n >>> list(spans([1,2,3,7,8,11,5]))\n [1:4, 7:9, 11:12, 5:6]\n\n# Release Log\n\n\n\n*Release 20230701*:\nAssorted bugfixes.\n\n*Release 20230619*:\n* Span: sanity check .start and .end.\n* Range.issubset: efficient comparison with another Range, also .issuperset.\n\n*Release 20230518*:\nSpan,Range: new as_list() methods.\n\n*Release 20190102*:\nSpan: provide __len__.\n\n*Release 20171231*:\n* Add Range.span0, returning the first Span.\n* Implement __bool__ and__nonzero__.\n* Accept a Span in __contains__.\n* Some small bugfixes.\n\n*Release 20160828*:\n* Add Range.start like existing Range.end.\n* Use \"install_requires\" instead of \"requires\" in DISTINFO.\n* Small bugfix.\n\n*Release 20150116*:\nFirst PyPI release.\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "a Range class implementing compact integer ranges with a set-like API, and associated functions",
"version": "20230701",
"project_urls": {
"Homepage": "https://bitbucket.org/cameron_simpson/css/commits/all",
"URL": "https://bitbucket.org/cameron_simpson/css/commits/all"
},
"split_keywords": [
"python2",
"python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d599c3b4892d99683458f83a744583340820428a7431883a2b7eb3d4e7edfb5f",
"md5": "dd2b5c16cdca7f3e0e476c16fc612a4c",
"sha256": "013607cfa0e3168153c02595fa8cbba364ef376d0e184bfcd8334e0143de3350"
},
"downloads": -1,
"filename": "cs.range-20230701-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dd2b5c16cdca7f3e0e476c16fc612a4c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7442,
"upload_time": "2023-07-01T02:31:09",
"upload_time_iso_8601": "2023-07-01T02:31:09.695202Z",
"url": "https://files.pythonhosted.org/packages/d5/99/c3b4892d99683458f83a744583340820428a7431883a2b7eb3d4e7edfb5f/cs.range-20230701-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7f7225c249904759e529c47aab5d3c822ce342afad46ab914c8ef18f4f1d17ac",
"md5": "a2d184a09626b6df156880ed248d0fec",
"sha256": "afe6cb75943fa80d0e84d8ade7b0a8e62a55f32a2a0ac2d9349f6fe9d88ae023"
},
"downloads": -1,
"filename": "cs.range-20230701.tar.gz",
"has_sig": false,
"md5_digest": "a2d184a09626b6df156880ed248d0fec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8329,
"upload_time": "2023-07-01T02:31:11",
"upload_time_iso_8601": "2023-07-01T02:31:11.315876Z",
"url": "https://files.pythonhosted.org/packages/7f/72/25c249904759e529c47aab5d3c822ce342afad46ab914c8ef18f4f1d17ac/cs.range-20230701.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-01 02:31:11",
"github": false,
"gitlab": false,
"bitbucket": true,
"codeberg": false,
"bitbucket_user": "cameron_simpson",
"bitbucket_project": "css",
"lcname": "cs.range"
}