moved iterators from Python to C++ for GetDistCpp.py