discer
Generic linear-time sorting and partitioning
Based on this paper by Fritz Henglein.
Warning before you start using this library
The standard libraries sorted function has linear-time sorting in the average case (Timsort) and is way more optimized than this library and will almost certainly be faster than any sorting done with this library.
discer.relations contains a Relation type that represents the Order and Equiv types from the paper along with a few of standard relations from the paper.
discer.grouping and discer.sorting contain the respective Equiv and Order based from functions from the paper.
Future work
Not in any particular order:
- Better README and docs
- Add some tests
- Optimize
- Lazy evaluation over the key/pair list to reduces passes on it
- Defer to
sortedwhen it will likely (or definitely) run in linear time - The paper includes some optimizations not included
- Generic Multiset Programming may also contain further optimizations
- Setup
SumLandProductLto useTypeVarTuple - Functions to extend Relations
list :: Relation a -> Relation [a]tuple :: Relation a -> Relation Tuple[a, ...]dict :: Relation a -> Relation Dict[k, a]
- Refactor
sdiscanddisc, the functions are basically exactly the same except how they deal withNatural - Add compatibility for at least Python 3.8+
References
Henglein, Fritz. "Generic top-down discrimination for sorting and partitioning in linear time." Journal of Functional Programming 22.3 (2012): 300-374.
Release files for discer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| discer-0.1.1.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| discer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / discer-0.1.1.tar.gz
| Download URL | discer-0.1.1.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6541ede377cba09054e0ca8a17531b444b53a36c36e9f472fc346cc0cfb955fa
|
|
BLAKE2b-256 checksum How to use checksums |
f148c6cfa0b70f462a535ad2e810eb031c5b527f4cdf1c201e90af2c880929a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.9
|
Release files / discer-0.1.1-py3-none-any.whl
| Download URL | discer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11cfcd60fb572662be0e04dbc5fddd1b40cbdc4dfc2bd5fb2ad1349ed2dc881e
|
|
BLAKE2b-256 checksum How to use checksums |
ccdcc3f72916fd599eabffc09066cf6deefd7b730a4874c7f2147714bf11f81a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.9
|