Looking through the code, prob_dist has type TopicProbDistribution which is vector<double> (in common.h).  So we could avoid this entire loop/serializing it to string/deserializing from string to vector in Python and just return the vector to Python as a numpy array of doubles.