From: Neil M. <Nei...@no...> - 2010-02-02 11:54:39
|
Hi Andy, On 1 Feb 2010, at 06:08, Andy Goth wrote: > (Is this the right forum for this type of discussion?) > > I believe it is possible to merge the list and dict Tcl_Obj types such that a dict is simply a list whose intrep contains some extra indexing information; dict extends list without replacing it, like a subclass. This change can be made without affecting script-level, API-level, or even binary-level compatibility. The only observable difference should be a performance improvement in some circumstances from reduced shimmering. Sounds good. If I understand correctly you add a hashtable to the list rep which maps from string keys to list indices, rather than directly to the associated value? Apologies, I don't have time to read through all the details you posted. This seems like a good approach to me. > > The idea came about while working on processing HTTP headers in Wibble. Headers can repeat, so I create a key/value list using [lappend] instead of [dict set]. Most of the time header repetition can be neglected, so the resulting list is conveniently accessed using [dict get], which returns the last (usually only) matching entry. However, this incurs a significant shimmering penalty for every lookup. If [dict get] were to access a persistent index over the list, rather than insisting on storing the values themselves in the index, this shimmering would not take place. (The Wibble version I describe hasn't been posted to the Wiki yet.) Presumably your direct concern could be solved by using [dict lappend] instead of [dict set]? I.e., instead of trying to create a map with duplicate keys, you instead store a list of values for each key. [...] -- NeilThis message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. |