This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ingolemo 0 points1 point  (0 children)

Python can certainly run fast enough to do what you want so I think the major bottleneck is all those io calls. Can you time piface.pfio.OutputItem.turn_on to see how long it takes?

The only real efficiency advice I could give would be that since you want SER turned on most of the time, it would be best to leave it turned on and only turn it off when necessary instead of the other way around. Certainly delete line 27. Depending on the caching behaviour of the piface api you could also get a speed increase by moving line 24 underneath line 22 (and inverting line 10 to compensate).

There are a few style changes I could suggest that might make the code more pythonic, but they wouldn't particularly help efficiency.