Show HN: Pyproc – Call Python from Go Without CGO or Microservices
📰 Hacker News · acc_10000
Call Python from Go without CGO or microservices using Pyproc, a library that runs a pool of Python worker processes and communicates over Unix Domain Sockets
Action Steps
- Install Pyproc using 'go get github.com/YuminosukeSato/pyproc@latest'
- Install pyproc-worker using 'pip install pyproc-worker'
- Define a Python worker function using the '@expose' decorator from pyproc_worker
- Run the Python worker using 'run_worker()' from pyproc_worker
- Call the Python function from Go using the Pyproc library
Who Needs to Know This
Backend developers and data scientists can benefit from Pyproc, as it allows them to reuse Python code and libraries in Go services without added complexity
Key Insight
💡 Pyproc enables low-overhead, process-isolated, and parallel calls to Python from Go
Share This
🚀 Call Python from Go without CGO or microservices using Pyproc! 🚀
Key Takeaways
Call Python from Go without CGO or microservices using Pyproc, a library that runs a pool of Python worker processes and communicates over Unix Domain Sockets
Full Article
Hi HN!I built *pyproc* to let Go services call Python like a local function — *no CGO and no separate microservice*. It runs a pool of Python worker processes and talks over *Unix Domain Sockets* on the same host/pod, so you get low overhead, process isolation, and parallelism beyond the GIL. *Why this exists* * Keep your Go service, reuse Python/NumPy/pandas/PyTorch/scikit-learn. * Avoid network hops, service discovery, and ops burden of a separate Python service. *Quick try (\~5 minutes)* Go (app): ``` go get github.com/YuminosukeSato/pyproc@latest ``` Python (worker): ``` pip install pyproc-worker ``` Minimal worker (Python): ``` from pyproc_worker import expose, run_worker @expose def predict(req): return {"result": req["value"] * 2} if __name__ == "__main__": run_worker() ``` Call from Go: ``` import ( "context" "fmt" "github.com/YuminosukeSato/pyproc/pkg/pyproc" ) fu
DeepCamp AI