I am trying to learn how to build a plugin. I forked Octoprint and I am on it.
In the code examples I am finding a curious expression that I would like to know the reason for its use:
if cmd and cmd == 'x':
Why not just:
if cmd == 'x':
One of the biggest reasons is that the first condition will be evaluated much faster which is important in the gcode hooks.
I imagined that this could be the intention but I thought that a case like that would be optimized in some way. Turns out not.
I also just read the advice not to put heavy computations in hooks. Well, little by little...