Add python reference implementation