Re: Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen <stk@xxxxxxxxxx>
- Date: Sun, 31 Dec 2006 12:30:25 +0100
Hello
Slightly off-topic. If you like that Python "trick" then you'd love
tcllib's fileutil::foreachLine. If you don't have tcllib then copy and
paste this to your file:
Thanks. I know Tcllib of course, but I did not use it, because it makes
things much more comfortable but much slower also. foreachLine is nice, but
when using Tcllib anyway, I would use fileutil::grep, which is also much
faster than foreachLine.
Nevertheless, your hint gave me the idea to try this one:
---
proc grep_for {} {
for {set f [open bigfile r]} {[gets $f line] >= 0} {} {
if {[string match -nocase "*destroy*" $line]} {
puts $line
}
}
}
---
Performance is nearly the same as the [while] version (while: 0.692s, for:
0.680s), but a little bit shorter.
Regards
Stephan
.
- References:
- Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Earl Greida
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: Stephan Kuhagen
- Re: Tcl faster than Perl/Python...but only with tricks...
- From: slebetman@xxxxxxxxx
- Tcl faster than Perl/Python...but only with tricks...
- Prev by Date: Re: Tcl faster than Perl/Python...but only with tricks...
- Next by Date: Re: Need example of ::cmdline::getfiles usage for newby
- 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):