migrate from fxxkin' c++ to python