a python rewrite of mpc