On Sat, Sep 4, 2010 at 2:15 PM, Jack Keegan <[email protected]> wrote:
> Hi girls & guys,
>
> Just joined the group. I'm new to Python but been picking it up pretty
> easy. I love it! I'm hoping to use it to make a controlling
> application for an experiment. Basically I want to use it to interface
> with some data acquisition (DAQ) hardware to accept incoming signals
> and respond sending signals to the outputs. I'm looking for an
> efficient State Machine algorithm as I need the timing to be as good
> as possible.
> As there is no switch statement in Python, I've been looking around
> for a good implementation. Most of the algorithms I've come across
> seem to be based on parsing applications. I'd like something more
> suited to my needs. I'd like to avoid excessive use of 'if-elif-else'
> statements as each would have to be checked to find the right
> conditions which would have an time overhead involved. I have seen an
> implementation of the switch using dictionaries but someone had
> commented that creating and throwing away dictionaries also comes at a
> cost.
> I was wondering if any of you could advise or point me in the right
> direction.

What sort of time do you have to do the processing (i.e. nanoseconds,
microseconds or milliseconds)?

My initial thoughts are to use a dictionary of the current_state/input
to next_state/action, this should be fairly clean. The contents of the
dictionary won't change so you need to create this only once.

I'd suggest benchmarking the solutions against what you need before
investing too much into optimisations.

Brian

> Any help would be greatly appreciated.
>
> Thanks,
>
> Jack
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Python Ireland" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/pythonireland?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Ireland" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pythonireland?hl=en.

Reply via email to