Python API

[WORK IN PROGRESS] Please do not merge.

This adds a Python version of the API using ctypes. It needs testing and polishing, but I open this PR early to get feedback.