Content-Type: BBCode ^ agreed. In this case, I think the problem is that your Python I/O reads in the WHOLE file into working memory before operating on it, while in your C++ version, you're reading in the file piecemeal, resulting in more I/O calls. Maybe (in the C++ version) reading the whole file into a string and then using an istringstream would make the I/O times more comparable? Also, using the '<' comparison for iterators is only defined for iterators supporting the RandomAccessIterator concept. While, admittedly, you are using a RandomAccessContainer (std::vector), it's generally more standard to use the not-equal comparison as the loop condition for anything supporting the Iterator concept.