0

I have quite some experience with coding in Delphi/Pascal and C++. So I know the basic concepts of writing code. But I'm pretty new to python. For this project I want to write the code in python. Explicitly not in Delphi.

I'm developping a rather small python-code for receiving data via UDP. But that's just a side-note. My real question is about redirecting output where data is sent to by using the print-command or some equivalent command like some kind of "write"

I'm also developping code with the arduino-IDE 1.8.19. The serial monitor of the Arduino-IDE is able to display hundreds of lines of "prints" in less than a second. This is a process of receiving the data through a virtual comport and then show it on the screen. Again the important aspect is: it is fast. very fast.

Despite the print output to the python shell is slow :-(

So I googled if there is a solution to speed up outputting to the python-shell. I found this stackoverflow-thread Why is printing to stdout so slow? Can it be sped up?

This thread is about linux-based computers. They are talking about re-directing stdout to /dev/null

The technical details about why writing to a file seems so much faster are discussed. (it is done through buffering)

Anyway the serial monitor of the Ardiuno-IDE demonstrates: displaying letters on the computers screen can be done fast. very fast.

So my question is: what ways can be used to speed up debug-output in python to make it much faster than the output to the python IDLE-shell?

Do I have to setup sending the data to a first virtual comport physically wiring the TTL-side of this first virtual comport to the TTL-side of a second virtual comport and let reading in the data by a classical terminal software like br@ys terminal

or is there a more direct way to do it?

The 2 virtual comports solution is very laborious and "poking from the back to the thorax into the eye"

The speed is there. As demonstrated by the java-based serial monitor of the arduino-IDE

So how can it be done with python in a more direct way? best reagrds Stefan

StefanL38
  • 9
  • 4
  • if `IDLE-shell` is too slow for you then don't run code in `IDLE` but directly in terminal. `IDLE` has to run extra code to display it because it doesn't write directly to terminal but it has to catch text from terminal or system and display it in GUI widget `tkinter.Text()`. – furas Aug 21 '22 at 09:23
  • all Python can be slower than Java and may need to change language. – furas Aug 21 '22 at 09:27

0 Answers0