[Python-Dev] Dictionary tuning

Jack Diederich jack@performancedrivers.com
Tue, 29 Apr 2003 00:36:36 -0400

On Mon, Apr 28, 2003 at 07:50:14PM -0400, Raymond Hettinger wrote:
> [jackdiederich]
> > You wouldn't have some created some handy tables of 'typical' dictionary
> > usage, would you?  They would be interesting in general, but very nice
> > for the PEPs doing dict optimizations for symbol tables in particular.
> That path proved fruitless.  I studied the usage patterns in about
> a dozen of my apps and found that there is no such thing as typical.
> Instead there are many categories of dictionary usage.
[symbol table amongst them]

A good proj would be breaking out the particular cases of dictionary usage and
using the right dict for the right job.

Module symbol tables are dicts that have a different 'typical' usage than dicts
in general.  They are likely even regular enough in usage to actually _have_
a typical usage (no finger quotes).

I've looked at aliasing dicts used in symbol (builtin, module, local) tables
so they could be specialized from generic dicts in the source and I get lost 
in the nuances (esp frame stuff).  If someone who did know the code well 
enough  would make the effort it would allow those of us who are familiar but
not intimate with the source to take a shot at optimizing a particular use 
case (symbol table dicts).  Alas, people who are that familiar aren't likely
to do it, they have more important things to do.


ps, I've always wanted to try ternary trees as symbol tables.  They have
    worse than O(1) lookup, but in real life are probably OK for symbol tables.
    They nest beautifully and do cascading caching decently.