Re: TclX loop slow in the default case
- From: Alexandre Ferrieux <alexandre.ferrieux@xxxxxxxxx>
- Date: Thu, 28 Aug 2008 00:35:14 -0700 (PDT)
On Aug 28, 3:03 am, "Donal K. Fellows" <donal.k.fell...@xxxxxxxxx>
wrote:
Alexandre Ferrieux wrote:
Why a wrong analysis ? How would you define [loop] in pure Tcl so that
it has the same performance as a [for] ?
In 8.5 and before, you can't because the body script will not be
compiled to have efficient access to local variables. (This might
change in 8.6 AIUI.) But apart from that you can get close:
proc loop {var from to body} {
upvar 1 $var v
for {set v $from} {$v <= $to} {incr v} {
uplevel 1 $body
}
}
What about [uplevel {for ...}] instead of [for ... uplevel] ?
(Miguel, what versions received your patch bringing compilation of
[uplevel] ?)
proc loop {var from to body} {
uplevel 1 [list for [list set $var $from] "\$$var<$to" [list incr
$var] $body]
}
-Alex
.
- References:
- TclX loop slow in the default case
- From: Evil Son
- Re: TclX loop slow in the default case
- From: Alexandre Ferrieux
- Re: TclX loop slow in the default case
- From: Evil Son
- Re: TclX loop slow in the default case
- From: Donal K. Fellows
- TclX loop slow in the default case
- Prev by Date: Re: record usage in tcl
- Next by Date: Re: Own implementation of multithread
- Previous by thread: Re: TclX loop slow in the default case
- Next by thread: Re: TclX loop slow in the default case
- Index(es):
Relevant Pages
|