Cython wrapper around GrailSort (https://github.com/gaming32/GrailSort-Maintained)
Project description
Join the Discord channel for live tech support!
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.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f53bb11598f7ad91f9f24605c2ef99f2878cacac7899b24e80b7339d02a0ed3 |
|
MD5 | 7691f1459189e69790fc8cc325211e48 |
|
BLAKE2b-256 | c1ac3a443cd1b2bdb10ce2bac8a15c394ff9c451b026291a65c0b956b8d054aa |
Hashes for GrailSort-1.2.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69e69bed6bb7152a37e837c143f115751a65bfa303c30c877ded08e921257fc7 |
|
MD5 | aa4c5295a1d2ba2011b9986f97f625a1 |
|
BLAKE2b-256 | bea6f8d5a92df312d2f5addcaa54b2854839665c9f705330434b01ba342cff46 |
Hashes for GrailSort-1.2.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17872b62e64434f3a73980bf00f8be11dd0045892fb740716a5dc02614e43c93 |
|
MD5 | 3bbaea65ddf326a1d6514d33391d4976 |
|
BLAKE2b-256 | 01075e54a6b7f22c6a29c77e68756575fddf09b14e6516f3e865a5113857e4c1 |
Hashes for GrailSort-1.2.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ccbe6786fc67ad7d7c2e13a6dc7f46c960180c15150f629dd238a0ca3bbfc49 |
|
MD5 | fd93c53664a771a5028ef2f6d13f992f |
|
BLAKE2b-256 | e0142b233982832205874739806a4df0b2413afeb5dc67892feae97a6dd4303b |