add python optimization