What are the advantages of working directly with stdin, stdout and stderr?

Asked

Viewed 108 times

2

Is there some advantage in terms of speed or some other aspect?

Shows the connections:

showConnections(all = TRUE)

Individual examples:

stdin()
stdout()
stderr()
  • 1

    John, could you clarify the question a little more? Is there an advantage over what, under what circumstances?

  • I have a Python script that sends R a simplified JSON on a line that I receive per stdin, do what I have to do and then return in the same format by stdout. I have tried to argue that you could send me JSON in another way but insist that this form is the best.

  • 1

    So I think it would be interesting to explain this content in the question! Abs

1 answer

2


To answer your question, let’s understand what your problem is and what the alternative solutions are. Your problem is to transfer data between two processes, R and Python. Here are some solutions to this problem:

  • Save the data in files that are accessed by both processes. Disk access is relatively slow. On the other hand, you do not need to re-run your programs to generate the data once they are written to disk.
  • Use network sockets. If both processes are on the same machine, communication is fast. The advantage is that your code will be prepared to transfer data between processes if they are placed on different machines.
  • Use stdin and stdout. In this case it will only work if both processes are on the same machine. Communication is fast. The advantage is that the code to read from the standard input and write to the standard output is quite simple.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.