Metadata-Version: 2.1
Name: discer
Version: 0.1.1
Summary: Generic linear-time sorting
Author-email: Brendan <brendandeleeuw@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Brendan DeLeeuw
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/MystiriodisLykos/discer/tree/v0.1.1
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE

# discer
Generic linear-time sorting and partitioning

Based on [this paper](http://hjemmesider.diku.dk/~henglein/papers/henglein2011a.pdf) by Fritz Henglein.

**Warning before you start using this library**

The standard libraries `sorted` function has linear-time sorting in the average case ([Timsort](https://en.wikipedia.org/wiki/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](http://hjemmesider.diku.dk/~henglein/papers/henglein2011c.pdf) 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.
