Code that ought to run fast, but can't due to Python limitations.

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Jul 6 08:54:03 EDT 2009


> protocol = {"start":initialiser,"hunt":hunter,"classify":classifier,....other
> states}
>
> def state_machine():
>     next_step = protocol["start"]()
>     while True:
>         next_step = protocol[next_step]()
>
>   
Woot ! I'll keep this one in my mind, while I may not be that concerned 
by speed unlike the OP, I still find this way of doing very simple and 
so intuitive (one will successfully argue how I was not figuring this 
out by myself if it was so intuitive).
Anyway I wanted to participated to this thread, as soon as I saw 'due to 
python limitations' in the title, I foretold a hell of a thread ! This 
is just provocation ! :-)

JM



More information about the Python-list mailing list