first python version.  similar quality to c version but should be easier to tinker with