while/break - The pure-python FSM implementation to Rule Them All.

Carl Cerecke cdc at maxnet.co.nz
Wed Jan 25 17:15:43 EST 2006


Paul Rubin wrote:
> Carl Cerecke <cdc at maxnet.co.nz> writes:
> 
>>3. Not as fast as byte code hacks, or using pyrex/psyco. Peter Hansen
>>is right. One of those is likely a better solution if you don't need
>>pure python.
> 
> 
> If you don't need pure python than your approach still beats
> everything else.  Just generate C code (or assembly code) instead of
> Python.

If you are generating C code, then you can, instead, use the much 
maligned goto to jump directly between states. All this 
while/break/continue hackery is just to emulate the humble goto.

Using gotos is probably about as fast as you can get.

Cheers,
Carl.



More information about the Python-list mailing list