I need suggestions on how to speed up access to python programs when called from Golang.  I really need fast access time (very low latency).
Approach 1:
func main() {
...
...
        cmd = exec.Command("python", "test.py")
        o, err = cmd.CombinedOutput()
...
}
If my test.py file is a basic print "HelloWorld" program, the execution time is over 50ms.  I assume most of the time is for loading the shell and python in memory.
Approach 2:
The above approach can be speeded up substantially by having python start a HTTP server and then gaving the Go code POST a HTTP request and get the response from the HTTP server (python).  Speeds up response times to less than 5ms.
I guess the main reason for this is probably because the python interpretor is already loaded and warm in memory.
Are there other approaches I can use similar to approach 2 (shared memory, etc.) which could speed up the response from my python code?.  Our application requires extremely low latency and the 50 ms I am currently seeing from using Golang's exec package is not going to cut it.
thanks,
Approach 1: Simple HTTP server and client
Approach 2: Local socket or pipe
Approach 3: Shared memory
Approach 4: GRPC server and client
In fact, I prefer the GRPC method by stream way, it will hold the connection (because of HTTP/2), it's easy, fast and secure. And it's easy moving python node to another machine.
Speed up access to python programs from Golang's exec packaqe