The following works:
import tables
const a = {"x": "Hello, ", "y": "world", "z": "!"}.toTable
echo a["x"], a["y"], a["z"]
Note the `const` part. The entire table (including keys and values) will
actually be allocated in static memory.
Whether you gain performance by avoiding hashing is something that you have to
consider on a case-by-case basis. It is unlikely that a linear search will be
faster for all but very short tables. Alternative data structures for a set of
string keys known at advance may be better (perfect hashing, tries or dfas, and
so forth).
Keep also in mind that unless it's a hot path, it may not matter at all. Do
some profiling first to check if it even matters for performance. You can do
some seemingly expensive stuff for code that's only executed once or a few
times and it won't show up at all on profiling. Your CPU can execute billions
of instructions per second. Anything that takes less than a million and doesn't
do that very often is just a rounding error in the grand scheme of things.