Performance with Python script & Touch Bar swipes

I have a two finger swipe gesture calling a python script action which sends data using requests.post() to an app. The response is quite juddery, I'm guessing because the gesture is repeatedly running Python? I wondered if there were any thoughts on improving this, making it flow a little better?

thanks

have you tried increasing the re-trigger distance a bit? (e.g. to 2-4%?)
Not sure how else this could be improved.

Seems to make it worse, although it's difficult to be sure

My intuition says keep Python resident, feed it values until fingers are lifted and the ship ends but I've no idea how practical that would be

Bigger values should definitely reduce the load, if that doesn't help I assume the issue is somewhere else.
I just tried running python MANY times with some basic script and couldn't feel any delay. Maybe the server is just slow to respond?

It's on localhost so it should be pretty quick. I'll run some tests, see if I can isolate it.

I had two groups with a left and right swipe in each. Intuitively I'd expect the swipes in groups only to work when that group is active but it seems not, they're active all the way up to the top level. So I think I was running 2 swipes concurrently. Removing the swipes from one group seems to have improved performance.

I also tried using an async AppleScript swipe. This definitely seems smoother.

Also, turning off the visibility tick box on a swipe doesn't prevent the swipe from working. I sort of expected it not to. Is that expected behaviour?

Returning to this, for the benefit of anyone interested; Applescript on the slider I'd expected to be quicker because slider movements call a callback function - bttWidgetSliderMoved() - suggesting it wouldn't be firing an app like Python. But Applescript doesn't support sockets, which means resorting to curl, which kind of negates the advantage. So I made my app scriptable and the performance issues just went away:

on bttWidgetSliderMoved(percentageMoved)

  set lua to "data=Params:IncCurrent( - Params.Step )"

  tell application "EarwigServer" to run code lua

end bttWidgetSliderMoved