Re: TclX loop slow in the default case
- From: "Donal K. Fellows" <donal.k.fellows@xxxxxxxxxxxxxxxx>
- Date: Wed, 27 Aug 2008 15:48:15 +0100
Alexandre Ferrieux wrote:
As you know of course, the near 3x speed gain for [for] is due to
bytecode compilation of its body, while TclX's [loop] command calls
Tcl_EvalObj at each turn.
That's not it. Tcl will store the bytecodes for the loop body in that
object and reuse them. (The recompilation hit is actually about 10x when
it strikes, BTW, assuming a trivial script body.) The real hit is
probably due to the fact that TclX still uses the string-based variable
API; if they used Tcl_ObjSetVar2 instead of Tcl_SetVar2Ex, they'd go
quite a bit faster as variable names would not need to be reparsed every
time through the loop. (And the reparsing involves a fair bit of memory
management too...)
I know this because I've just checked the relevant code (tclBasic.c and
tclXgeneral.c FYI).
This experiment IMO fuels the idea that preprocessing could help in
Tcl too from time to time: it would allow to define countless such
variants of Tcl's optimized control primitives without losing the
performance.
That's the "LISP solution". And it turns out it's a wrong analysis in
this case. :-)
Donal.
.
- 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
- TclX loop slow in the default case
- Prev by Date: Re: spinbox bug?
- Next by Date: Re: spinbox bug?
- Previous by thread: Re: TclX loop slow in the default case
- Next by thread: Re: TclX loop slow in the default case
- Index(es):