#!/usr/bin/env python3

import ctypes
import os
import glob

import numpy as np


# Load the Rust library when loading this module

target = "debug"
# target = "release"

libpath = os.path.join("target", target, "libsorting.*")
libfile = glob.glob(libpath)[0]
rustlib = ctypes.CDLL(libfile)

def quicksort(array):
    rustlib.ffi_quicksort_i8(ctypes.c_void_p(array.ctypes.data), len(array))

@@ -307,19 +307,22 @@
 array):%0A
+%0A
    
+ #
  rustlib
@@ -339,56 +339,911 @@
 sort
-_i8(ctypes.c_void_p(array.ctypes.data), len(array)
+(%0A        # ctypes.c_void_p(array.ctypes.data), len(array), b%22i32%22%0A    # )%0A%0A    ptr = ctypes.c_void_p(array.ctypes.data)%0A    n   = len(array)%0A%0A    if array.dtype == np.int8:%0A        rustlib.ffi_quicksort_i8(ptr, n)%0A    elif array.dtype == np.int16:%0A        rustlib.ffi_quicksort_i16(ptr, n)%0A    elif array.dtype == np.int32:%0A        rustlib.ffi_quicksort_i32(ptr, n)%0A    elif array.dtype == np.int64:%0A        rustlib.ffi_quicksort_i64(ptr, n)%0A%0A    elif array.dtype == np.uint8:%0A        rustlib.ffi_quicksort_u8(ptr, n)%0A    elif array.dtype == np.uint16:%0A        rustlib.ffi_quicksort_u16(ptr, n)%0A    elif array.dtype == np.uint32:%0A        rustlib.ffi_quicksort_u32(ptr, n)%0A    elif array.dtype == np.uint64:%0A        rustlib.ffi_quicksort_u64(ptr, n)%0A%0A    elif array.dtype == np.float32:%0A        rustlib.ffi_quicksort_f32(ptr, n)%0A    elif array.dtype == np.float64:%0A        rustlib.ffi_quicksort_f64(ptr, n
 )%0A

Call the proper quicksort version depending on type.