Re: Tcl faster than Perl/Python...but only with tricks...



Ian Bell wrote:

I am no expert but presumably, not matter what the language, the gets or
read ends up as an fgets C library call. Is it possible the differences
are due in part to the way each language sets up the channel e.g buffer
size, blocking, no chars read in fgets etc?

I'm starting to suspect this also, as well as what Alexandre Ferrieux wrote
about translation and encoding. Maybe there are some settings for buffering
and encoding/translation that can make [gets] as fast as the readlines of
Perl/Python. Knowing those settings (or some good heuristics depending on
the task and environment) could be a great improvement and mentioned in
some tutorial, the man pages or something.

If it's not that, maybe a look at the implementation of [gets] comparing it
to the same things in Python and Perl (no way!) would reveal some
interesting differences.

Regards
Stephan
.



Relevant Pages

  • system() and _flushall()
    ... You must explicitly flush (using fflush or _flushall) or close any stream ... However, on the next read from the input file using fgets, I get ... forgotten that there's still data in the buffer (the buffer is not destroyed ...
    (microsoft.public.vc.language)
  • Re: *scanf in Harbison and Steele
    ... The difference between fgets and gets is at least that fgets takes ... the output buffer. ... Though I've been told that stdin come with the food in C, must you declare: ...
    (comp.lang.c)
  • Re: user input, getchar, and buffer - For C beginners and those with teaching skills...
    ... buffer: video streaming, printer jobs. ... > Fgets unlike scanf has a limit in the number of caracters ... to read any newline left (here it would be located in array> "chaine" ... than 20 characters and keeps it in the buffer? ...
    (comp.lang.c)
  • Re: Replacing fgets
    ... OK, for the sake of discussion, replacing fgets() with some type ... and you just want to do some simple parsing and searching. ... the START of the line in the buffer, ...
    (comp.lang.c)
  • Re: Replacing fgets
    ... OK, for the sake of discussion, replacing fgets() with some type ... of equivalent function where you START with a unopened file really ... reset the buffer position. ... if you only want to set buffer position, ...
    (comp.lang.c)