Skip to main content

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 sorted when 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 SumL and ProductL to use TypeVarTuple
  • Functions to extend Relations
    • list :: Relation a -> Relation [a]
    • tuple :: Relation a -> Relation Tuple[a, ...]
    • dict :: Relation a -> Relation Dict[k, a]
  • Refactor sdisc and disc, the functions are basically exactly the same except how they deal with Natural
  • 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)

Source distribution for discer 0.1.1
File Size Uploaded
discer-0.1.1.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for discer 0.1.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page