Version 0 of Some observations on behind-the-scenes actions of Tcl

Updated 2008-02-24 01:38:28 by hans

1. I keep a large collection of text data as a list in memory {text...} 2. I want to search this data.

Here's what happens.

  set match [lsearch -regexp $x {needle}]

-> memory usage of the list raises by about 200%(total memory usage before: 80MB, after: 200MB)

  foreach k $x { if {[regexp -nocase {needle} $k]} {puts "match"} 

- >ditto

  foreach k $x { if {[regexp -nocase {needle} [list $k]]} {puts "match"} 

-> Heureka! total memory usage stays at 80MB.

I'm still not quite sure what's going on, I'm now consulting these pages: shimmering pure list.


enter categories here