Python(2.5) reads an input file FASTER than pure C(Mingw)
n00m
n00m at narod.ru
Sat Apr 26 16:12:43 EDT 2008
>> char vs[1002000][99];
In the file 1001622(or so) records like phone number + f/l names.
So the reserving makes sense, i think. Populating of vector<string>
is by zillion times slower.
>> Is there an implementation of f.readlines on the internet somewhere?
I was greatly surprised how fast it is. As a matter of fact, it's the
point
of my message here.
>> BTW why are you declaring the array as 99 and pass 999 to fgets to read a
line?
It doesn't matter. All the same, reading of a current line stopped at
'\n'.
Big number 999(9999,99999,...) just ensures that each line is read up
to its end.
>> fgets is part of the standard C++ library and it lives in the std
namespace.
I thought it's from <stdio.h>. Anyway, it does not matter. PS Thanx
for the code.
2All:
Origin of my "discovery" is from http://www.spoj.pl/ranks/SBANK/start=400
I never thought it can be done in Python (there are a couple of Py
solutions
even faster than mine) and without stuff like radix sort etc.
More information about the Python-list
mailing list