How to speed up a fabric run() call


I use fabric on Windows 10 to connect to, and run, a python script on Ubuntu VM (installed locally on Windows). The script takes 7-8 seconds to run. How can it be sped up?

Script running on the VM (

print('returned value')

Calling script from Windows:

from fabric import Connection
c = Connection('vm-name', port=22, user='username', connect_kwargs={'password': 'my_pwd'})
import io
f = io.StringIO()