On Fri, 03 Dec 2004 14:48:30 -0800, Scott David Daniels
<[EMAIL PROTECTED]> 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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to