tags:

views:

117

answers:

2

I use a file to communicate between Python and Ruby script. But, we have mmap. So here are my questions.

  • Can I do the same thing (communicate between processes) with mmap?
  • What advantage can mmap give us over physical file? Speedup?
  • What would be the easiest way to communicate between two processes?
  • What would be the fastest way to communicate between two processes?
+2  A: 

one advantage of mmap over physical file is indeed speedup, but anything is going to be faster than a physical file !

the easiest way to communicate between to processes is either a pipe or a socket. they are easier because they are streams, so they do not impose a limit on the length of the data you can exchange between the processes, contrary to a file or a mmap which have bounds.

Adrien Plisson
I guess one place that the mmap would have an advantage over sockets would be if something huge would have to be shared among the scripts. But for simple IPC sockets would be better.
daramarak
A: 

It might depend on what you want to communicate. If you are just giveing a massive data set from one app to the other then mmap files might make sense. If you have messages then some sort of IPC/RPC protocol may be better. If you are streaming data from one app to the other pipes/sockets might be better.

With mmaps you still have to manage them as a file and so you have to open and close them in a way that will synchronise. This may affect performance, and so you may want to use streams/pipes.

Nick