Cython wrapper around GrailSort (https://github.com/gaming32/GrailSort-Maintained)
Project description
GrailSort for Python
GrailSort for Python is a Python API for the GrailSort algorithm.
Installation
You can install GrailSort for Python from source:
$ git clone https://github.com/gaming32/grailsort
$ cd grailsort
$ python setup.py install
Or you can install it from PyPI:
$ python -m pip install GrailSort
Usage
GrailSort for Python comes with two modules: a strict one, and a slower one. The strict module (cGrailSort
) only deals with array.array('d')
objects, while the slower module (grailsort
) deals with any Python sequence that contains comparable objects.
It is generally unnescessary to deal with the grailsort
module, as you might as well use the built-in list.sort
method or the sorted
function. However, TimSort is not in-place, while GrailSort is. cGrailSort
is useful when you need to sort with speed.
Example
grailsort
import grailsort
import random
def print_out_of_order_index():
index = next((i for i in range(len(l) - 1) if l[i] > l[i + 1]), None)
print('Out of order index:', index)
l = list(range(1024))
print_out_of_order_index()
random.shuffle(l)
print_out_of_order_index()
grailsort.grailsort(l)
print_out_of_order_index()
cGrailSort
import cGrailSort
import array
import random
def print_out_of_order_index():
index = next((i for i in range(len(a) - 1) if a[i] > a[i + 1]), None)
print('Out of order index:', index)
a = array.array('d', range(1024))
print_out_of_order_index()
random.shuffle(a)
print_out_of_order_index()
cGrailSort.grailsort(a)
print_out_of_order_index()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for GrailSort-1.2.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3921ba24fc531ae2278afc0a49ea62187e40cb0446bc062972917ae7611b3de6 |
|
MD5 | 802778dea74f08c21916abbb0930cd62 |
|
BLAKE2b-256 | 5fb3d1ad15cf65ea45e4f2a1b8c466939140c15a767a5c9b292a7f97b49a2992 |
Hashes for GrailSort-1.2.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 190272999ebadb666ba0b0a1df8b4391bf1e6a2aea1d8eb2ed0fe5701cd49526 |
|
MD5 | 95dbee48915113b813caf764644afc7c |
|
BLAKE2b-256 | 0248052206450a4c3dbd1fa2fbf285d549369a7f535057067553574f3903bb2b |
Hashes for GrailSort-1.2.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c6284ec5abf7f376254001de6cb3d84383f59d1436a87c3881318fb17703e70 |
|
MD5 | 758db092ccbb3ea73debf0af51d09057 |
|
BLAKE2b-256 | f747245e449060fb46cbdab5566f60af3eca4934efb846edc568ae167f5d32e4 |
Hashes for GrailSort-1.2.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73535779a237bb5a95757f291a09f449befe197049908d62b77149e75afcbe58 |
|
MD5 | 8467e1f11458bc0bdb776e1ddd82c913 |
|
BLAKE2b-256 | f770c9d53de4c4c1c3ecf005960b047faa428ec8a9475890bdde7b727c4df567 |