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



Earl Greida wrote:

"Stephan Kuhagen" <stk@xxxxxxxxxx> wrote in message
news:en5klt$7fa$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

On my computer (Linux 2.6.18, 2.6 GHz Pentium 4)..
0.273s for Perl
The Python-Version was....0.622s.
Tcl...0.937s

To me, the question is how often does the program need to read the 8.2MB
file. If every second then the time difference matters. If once a minute
then the few hundred milli-second difference becomes less important. If
only a few times then the time difference is essentially irrelevant. The
question becomes, which language is easier to use, and produces a program
that is easier to read, easier to maintain, easier to enhance, and more
reliable, over the life of the program.

This is quite right. The Perl-Version (for me) is not as readable as the Tcl
or the Python version. But Pythons "for line in file" is really simple and
good looking. Additionally one doesn't build such a script to run this task
only once. For that you simply use a one-liner or grep and do not care if
it runs half a second or three seconds. So this is of course an academical
example. But if you really often do those tasks on really big files, then
this will make a difference. I had such an example, and luckily Tcl won,
because of its faster regexp compared to Python. But if the checks I had to
do on the data were more simple and could have been done without regexp but
with simple string matching, Python would have been some times faster. And
since this specific task runs about in a loop some hundred times every ten
minutes, the runtime of the script has some serious impact. For me, the
slowness of [gets] doesn't do any harm to my preference to Tcl. But I was
really wondering, why reading strings from a file is so slow compared to
the others, because I have the feeling, that for many tasks this is a very
central bottleneck.

Regards
Stephan
.



Relevant Pages

  • Re: Perl / python regex / performance comparison
    ... I know this is not a direct python question, forgive me for that, but ... I looked around and found perl and python to be the nice. ... In your opinion, for handling large files, ... For one file and simple processing, the time difference should be less than the time you spent asking the question. ...
    (comp.lang.python)
  • Re: TCL with Perl or Python?
    ... Now that you mentioned web guis, tcl is far behind on this :-( ... I want to add a small web gui to an existing app, and still I haven't found a solution... ... using Python or Perl. ...
    (comp.lang.tcl)
  • Re: Tcl faster than Perl/Python...but only with tricks...
    ... I have tried some small variations by mimicking your first python code. ... the tcl code that does similar to the python code is: ... python python.py: 582543 microseconds per iteration ...
    (comp.lang.tcl)
  • Re: Choosing Perl/Python for my particular niche
    ... >I was under the impression that Tcl ... >it's good to know that Tcl is an option to Perl and Python, ... >algorithms for programming coarse grain reconfigurable ...
    (comp.lang.perl.misc)
  • Re: Choosing Perl/Python for my particular niche
    ... >I was under the impression that Tcl ... >it's good to know that Tcl is an option to Perl and Python, ... >algorithms for programming coarse grain reconfigurable ...
    (comp.lang.python)