Speed issue when reading sensor data with pyfirmata

Hi,

I salvaged a motor with an optical encoder from a laser printer.

I'm trying to count the holes in the disc using the pyfirmata-protocol,
but I have the impression that the communication is too slow.

Any suggestions how I can achieve this using python ?
Should I use a sketch that directly handles the optical encoder steps ?

How would I communicate this to a python script ?

Thanks !!

Should I use a sketch that directly handles the optical encoder steps ?

Generally: yes!

How would I communicate this to a python script ?

By a serial protocol? You can even emulate the firmata protocol if that makes it easier for you.