title: Very slow interaction using Python's telnetlib
body: <p>I'm writing a Python script that connects to a Linux terminal over Telnet, runs a number of commands and parses the output, then based on the output runs more commands, etc.</p>
  
  <p>This was quite easy to set up using <a href="http://docs.python.org/2/library/telnetlib.html" rel="noreferrer">telnetlib</a>. I'm using write(cmd + '\n') to send the command and then read_until(prompt) to read the output. The problem I'm having is that this setup seems to be very slow. Every command takes maybe around 100-200 ms to run. This makes the total run time around half a minute, which I find to be too long.</p>
  
  <p>If I connect to the terminal using a normal Telnet client the commands I'm trying to run return near instantly. I've also made a small bash script that runs ~20 commands that also returns near instantly. Also I tried some of the other read functions in telnetlib (such as read_very_eager()) without any improvement.</p>
  
  <p>Does anyone know why this setup is so slow and if there's anything I can do about it?</p>