Added Python reference implementation