I need a dictionary, "just for the keys", that is, the values are of lesser importance. Which value will consume the least amount of memory? "0" "", something else? Thanks.
Tcl shares constants under the covers, so you can use pretty much anything as long as it is a literal. But the empty string is almost certainly going to be a pre-defined constant in your script anyway (even if you don't notice it) and is pretty short. Or go with a single-character alphanumeric string, which will generate a shorter string form of dictionary (and have practically no difference otherwise). A 0
is a single-character alphanumeric string, of course.
In my own code, I would mostly use something like "dummy value"
for the value. The cost is only a few bytes total more most of the time, and yet it's much clearer to me that it doesn't mean anything, so if I come back to the code later I don't try to figure out what I was doing with the value…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With