add python reference implementation

useful for testing later