Mapping with continguous ranges of keys
rosuav at gmail.com
Fri Dec 16 16:28:29 EST 2016
On Fri, Dec 16, 2016 at 4:06 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> I have about a million or two keys, with a few hundred or perhaps a few
> thousand distinct values. The size of each contiguous group of keys with
> the same value can vary from 1 to perhaps a hundred or so.
Going right back to the beginning here: I think that "a million or
two" is a perfectly doable figure for a straight-forward list or dict.
You get immediately-available lookups in a straight-forward way, at
the cost of maybe 16MB of memory (if you use the same strings for the
values, the cost is just the pointers).
More information about the Python-list