Skip to content

Instantly share code, notes, and snippets.

@gandroz
Last active May 5, 2021 14:25
Show Gist options
  • Save gandroz/7e2ad2ffbdf9483527dfee0ec6cdef0b to your computer and use it in GitHub Desktop.
Save gandroz/7e2ad2ffbdf9483527dfee0ec6cdef0b to your computer and use it in GitHub Desktop.
Load C module helper function
def load_module():
# load library
cmodule = ctypes.cdll.LoadLibrary('./levenshtein.so')
# define arguments type
cmodule.levenshtein.argtypes = [ctypes.c_char_p,
ctypes.c_char_p,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int]
# define return type
cmodule.levenshtein.restype = ctypes.c_int
return cmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment