Possible dict performance enhancement
Open2832003fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-08-04 13:33:17
[from comp.lang.tcl] A quick glance at the code appears to show rehashing when copying Dict objects. Either I have missed something or this is an unnecessary waste of time as surely you can just allocate copies of the ChainEntry instances from the old dict and fix up the pointers. One might even think of elevating ChainEntry to a first class, reference counted, Tcl object thus allowing even greater sharing between dicts such that variable altering dict operations on shared dict values could cause ChainEntry objects to be shared thus requiring only a few allocations (The altered key/value ChainEntry and its predecessor) whatever the size of the dictionary.
dkfplain2009-08-05 21:31:37
First-class ChainEntry... that's unlikely as it's a member of (at least) two linked lists, one for the hash table and the other for the dictionary iterator. Faster copy... theoretically yes, but in practice I'm less keen as it involves poking more deeply behind the scenes of the hash table implementation. I've tried to avoid that so far, but it would be possible in the future if this is identified as an important bottleneck.
Log in (anonymous is fine) to add a comment.