add python implemtnations and better CPP version