Re: Tcl faster than Perl/Python...but only with tricks...
- From: "Donal K. Fellows" <donal.k.fellows@xxxxxxxxxxxxxxxx>
- Date: Sun, 31 Dec 2006 11:39:06 GMT
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.
Certainly not! fgets() is a part of stdio and Tcl doesn't use that
because it's buffering interacts badly with use of select() in Tcl's
notifier. Instead, Tcl manages everything over the OS's syscall level
(i.e. read() or recv() on Unix, depending on channel type) so that it
can get the interaction between the various pieces right.
If you want a speed boost, make sure that the channel is configured to
use -translation binary and use [read]. That turns off a lot of
processing that would otherwise slow things down. Also, if your file is
only a few percent of your available physical address space in size,
then slurping it all into memory is best anyway. :-)
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?
The differences quite possibly also relate to how languages handle their
internal string representations. Processing as byte arrays is definitely
faster (though wrong with some rare system encodings, but I bet Tcl does
better with those than other languages do). As noted above, put the
channel in binary mode (8.5 will make this easier to do BTW) and then
use [read] for a speed boost.
Donal.
.
- Follow-Ups:
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen
- Re: Tcl faster than Perl/Python...but only with tricks...
- References:
- Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: George Petasis
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Alexandre Ferrieux
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Uwe Klein
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Ian Bell
- Tcl faster than Perl/Python...but only with tricks...
- Prev by Date: Re: unicode normalization
- Next by Date: Re: Improving i18n support (Was: Re: Christmas
- Previous by thread: Re: Tcl faster than Perl/Python...but only with tricks...
- Next by thread: Re: Tcl faster than Perl/Python...but only with tricks...
- Index(es):
Relevant Pages
|