A series of C API examples taken & modified from http://dan.iel.fm/posts/python-c-extensions/ and  https://gist.github.com/beaylott/3313315