add python implementations and tests