Skip to main content

Cython interface to GNU Parallel sorting routines

Project description

parallel-sort

Test build PyPI version

This module provides a simple Cython interface to parallel sorting algorithms available in C++. It provides functions for in-place and out-of-place sorts, as well as indirect sorting (aka. "argsort").

By default it requires a C++17-capable compiler, and will use the parallel execution policy introduced in that standard. For older compilers without C++17 support, the GNU Parallel Mode sorting routines may be used instead.

Usage

import parallel_sort
import numpy as np

x = np.random.random(size=10000)

x_sorted = parallel_sort.sort(x)

assert np.all(np.diff(x) >= 0) # x is now sorted

Installing

Requirements: numpy, OpenMP, C++17-capable g++, Cython (only for installation from source).

Installing from wheel via pip should "just work":

pip install parallel_sort

Alternatively, the module can be built for older compilers that do not support C++17, but do supply the GNU Parallel Mode library. To build without C++17, clone the repository and set use_cxx17 = False in setup.py. Then run:

pip install -e .

to compile and install the module.

Installation has been tested on linux (Ubuntu, CentOS) and Mac (via Homebrew).

Note for Apple Silicon Macs

If the module builds OK, but importing it fails with an error "undefined reference to aarch64_ldadd4_acq_rel", try rebuilding with the following command (substituting your gcc version as appropriate):

CFLAGS=-mno-outline-atomics CC=$(brew --prefix gcc)/bin/gcc-13 pip install --no-cache-dir -e .

Project details


Download files

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

Source Distribution

parallel-sort-0.1.1.tar.gz (176.4 kB view hashes)

Uploaded Source

Built Distributions

parallel_sort-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

parallel_sort-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

parallel_sort-0.1.1-cp39-cp39-manylinux_2_28_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

parallel_sort-0.1.1-cp38-cp38-manylinux_2_28_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

parallel_sort-0.1.1-cp37-cp37m-manylinux_2_28_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.28+ x86-64

parallel_sort-0.1.1-cp36-cp36m-manylinux_2_28_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.28+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page