GUI Frames and classmethod

Zak Arntson zak.arntson at gmail.com
Mon Dec 6 14:34:33 EST 2004


On Fri, 03 Dec 2004 14:48:30 -0800, Scott David Daniels
<scott.daniels at acm.org> wrote:
> Zak Arntson wrote:
>  > My current approach is that in the Frame class, I have a method to
>  > call _after_ initialization that creates a bunch of dummy methods so
>  > the user doesn't have to implement EVERY state change method in a
> 
> Really, I think the above is a bad idea.  Don't implement empty
> methods.  Make a dictionary of state transitions, and store code in it.
> Note: you don't need a dictionary of dictionaries; you could use a
> dictionary of pairs.  Do something on each attempted transition like the
> following:

A dictionary of methods! Thanks. Boy, do I feel silly now. So I have a
more general question: A dictionary of dictionaries is slower than a
dictionary of tuples, right? Because when Python accesses a
dictionary, it produces a hash from the key and finds that in its hash
table. Producing a hash from a tuple is much faster than producting
two hashes and doing two lookups. At least that's what I'm assuming.

-- 
Zak Arntson
http://www.harlekin-maus.com - Games - Lots of 'em



More information about the Python-list mailing list