Slow Itcl class variable lookup

From: David N. Welton (davidw_at_dedasys.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 17:20:35 GMT


proc timeprint {script} {
    return [lindex [uplevel [list time $script 1]] 0]
}

::itcl::class Book {
    public variable idnum
    public variable title foo
    public variable category bar
    public variable subcategory
    ...
}

set i 0
while {$i < 10000} {
    lappend cl [Book \#auto]
    incr i
}

foreach c $cl {
    puts [timeprint { set ttl [$c cget -title] }]
    puts [timeprint { set cat [$c cget -category] }]
}

Reports values like these:

100
93
101
92
100
93
100
93

Which seems ok. The problem is that for similar code in my program,
I'm getting much larger numbers:

374
364
369
389
372
364
366
427
381
367
368

and since I'm dealing with a lot of objects, this slows things down a
lot:-/ Any ideas on what could be causing this, or how to speed it up?

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/


Relevant Pages

  • Re: A different design for closures
    ... > incr x ... > foo and bar will share the same 'a'. ... There is a typo here, ...
    (comp.lang.tcl)
  • Re: Insert with response
    ... FooBar, there's no way and no need to put them in synch. ... column in the foo table to 250 calumns in the bar table. ... set statistics time off ...
    (microsoft.public.sqlserver.programming)
  • Re: Magic function
    ... processing objects created in root at depth 3 ... root obj2 at depth 3 ... processing objects created in foo at depth 2 ... processing objects created in bar at depth 0 ...
    (comp.lang.python)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... Unfortunately this is a side effect of using the os's directory structure to represent a python "package" structure. ...
    (comp.lang.python)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... A path below the package level is generally a good means to shoot ... to represent a python "package" structure. ...
    (comp.lang.python)