Python(2.5) reads an input file FASTER than pure C(Mingw)

n00m n00m at narod.ru
Sun Apr 27 15:54:48 EDT 2008


Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8)

Compare 2 my latest submissions: http://www.spoj.pl/status/SBANK,zzz/

times: 1.32s and 0.60s

Submitted codes:

import sys
z=sys.stdin.readlines()
print z[5]


#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

vector<string> vs;

int main() {
    while (true) {
        char line[50];
        if (!fgets(line,50,stdin)) break;
        vs.push_back(line);
    }
return 0;
}


If it proves nothing then white is black and good is evil



More information about the Python-list mailing list