News for hackers. Stuff that matters.
Re:How fast is fscanf? by saretired on Monday October 06, 2014 @06:33AM (#8415114)
The C program isn't doing the same thing. It overwrites the array of variables each time it scans a line. numpy.loadtxt returns an array of the parsed lines. So you'd need to do some dynamic allocation to store the parsed values. If the number of fields per input line isn't hardcoded, you'll need to walk sscanf() across each input line while managing input and output buffers (you can call read(), which is much faster, but you'll need to handle partial line reads). numpy.loadtxt has additional capabilities, all of which add per-line overhead. A fully functional clone of loadtxt in C is unlikely to run enormously faster, i.e. enough to justify the programming involved. In any case, this toy exercise isn't testing the speed of fscanf() in a meaningful way.

There are no comments on this comment yet.