> I use lists of lists as a data stucture. I can reduce memory usage by
> using a cursor to fetch records from the database but sometimes it is
> useful to cache or serialize the data so that I can seperate data from
> presentation or provide a database abstraction layer.
> I had a look at trying to create data structures using a list of ns_set
> references and a list of array references but a list of lists turned out
> to be the fastest.

list of lists is a very efficient structure in Tcl since 8.0.  Tcl
"lists" are really C arrays of Tcl_Obj's.  lindex is an O(1) op,
and 8.4 supports multi-level lindex, as in:

set l {
  {0,0 0,1}
  {1,0 1,0}
}

(Tcl) 50 % lindex $l 0 0
0,0
(Tcl) 51 % lindex $l 1 0
1,0
(Tcl) 52 % time {lindex $l 1 0} 1000
1 microseconds per iteration

Previously this would be done with pseudo-indexed arrays, which used
more memory (the key itself was a string).

Jeff


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to