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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discer-0.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

discer-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file discer-0.1.1.tar.gz.

File metadata

  • Download URL: discer-0.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.9

File hashes

Hashes for discer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6541ede377cba09054e0ca8a17531b444b53a36c36e9f472fc346cc0cfb955fa
MD5 49bfa85bad55080a642c7dda86a30b90
BLAKE2b-256 f148c6cfa0b70f462a535ad2e810eb031c5b527f4cdf1c201e90af2c880929a7

See more details on using hashes here.

File details

Details for the file discer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: discer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.9

File hashes

Hashes for discer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11cfcd60fb572662be0e04dbc5fddd1b40cbdc4dfc2bd5fb2ad1349ed2dc881e
MD5 34941e7404101f900a950b5d49b5c6cf
BLAKE2b-256 ccdcc3f72916fd599eabffc09066cf6deefd7b730a4874c7f2147714bf11f81a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page