I wrote:
> Re: efficiency: My experience is that one can have TeX do quite 
> extensive processing without slowing things down much *provided one does 
> it in the mouth*. (I don't understand quite why that would be, but did 
> some timing to confirm it in particular cases for fontinst v1.913.) A 
> set of workable semantics for a fully expandable
>   \DictionaryGet{<key>}{<dictionary>}{<default>}
> command would be:
> 
> 1.  \DictionaryGet{#1}{\ToDictionary{#2}{#3}}{#4}
>   fully expands to the full expansion of #3 if the full
>   expansion of #1 is equal to the full expansion of #2,
>   and to the full expansion of #4 otherwise; probably
>   equivalent to
>     \str_if_eq:xxTF{#1}{#2}{#3}{#4}
>   (or would that be \str_if_eq:nnTF?).
> 
> 2.  \DictionaryGet{#1}{\ToDictionary{#2}{#3}#4}{#5}
>   is after full expansion equivalent to
>     \DictionaryGet{#1}{\ToDictionary{#2}{#3}}{
>       \DictionaryGet{#1}{#4}{#5}
>     }
> 
> 3.  \DictionaryGet{#1}{}{#2}
>   is after full expansion equivalent to #2.
> 
> The trickiest thing to do in TeX3 is the test for key equality, and I 
> believe there has been discussions about newer engines having primitives 
> that simplify this. (Not having to go via 
> \expandafter\string\csname<key-name>\endcsname to sanitize key names is 
> a good first step, although not essential.)

Following up on that: As a proof of concept, I implemented (for 
TeX3/LaTeX2e) such a \DictGet command last night; see attached files 
(<6K with source documentation and tests). Complexity is linear in the 
size of dictionary values, but worst-case quadratic in the average size 
of a key.

10000 look-ups (9988 of which won't find anything) in a dictionary of 
12 elements took 12.114s on a fairly old (500MHz) iBook. Seems 
acceptable to me.

Lars Hellström