mostly completed c++/cython/python API attempt 2