add Python implementation