Regular expression as dictionary key?
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Dec 3 05:08:09 EST 2001
Luke <LLoeffler at home.com> wrote in news:3C0B408C.8030908 at home.com:
> I admitedly don't know much about
> the C implementation of dicts, but it seems there should be a way to
> leverage the dict's arrangement for fast regex keys.
>
I think your problem here is assuming that the dict's internal arrangement
is in some way sorted. It uses a hash table, not a binary tree, so there is
no obvious way that you can improve on a linear search for this kind of
lookup.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list