Move C library code into Python.