{"by":"acc_10000","descendants":9,"id":45257929,"kids":[45259626,45259078,45263748,45260095,45260861],"score":40,"text":"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&#x2F;pod, so you get low overhead, process isolation, and parallelism beyond the GIL.<p>*Why this exists*<p>* Keep your Go service, reuse Python&#x2F;NumPy&#x2F;pandas&#x2F;PyTorch&#x2F;scikit-learn.\n* Avoid network hops, service discovery, and ops burden of a separate Python service.<p>*Quick try (\\~5 minutes)*<p>Go (app):<p>```\ngo get github.com&#x2F;YuminosukeSato&#x2F;pyproc@latest\n```<p>Python (worker):<p>```\npip install pyproc-worker\n```<p>Minimal worker (Python):<p>```\nfrom pyproc_worker import expose, run_worker\n@expose\ndef predict(req):\n    return {&quot;result&quot;: req[&quot;value&quot;] * 2}\nif __name__ == &quot;__main__&quot;:\n    run_worker()\n```<p>Call from Go:<p>```\nimport (\n  &quot;context&quot;\n  &quot;fmt&quot;\n  &quot;github.com&#x2F;YuminosukeSato&#x2F;pyproc&#x2F;pkg&#x2F;pyproc&quot;\n)\nfunc main() {\n  pool, _ := pyproc.NewPool(pyproc.PoolOptions{\n    Config:       pyproc.PoolConfig{Workers: 4, MaxInFlight: 10},\n    WorkerConfig: pyproc.WorkerConfig{SocketPath: &quot;&#x2F;tmp&#x2F;pyproc.sock&quot;, PythonExec: &quot;python3&quot;, WorkerScript: &quot;worker.py&quot;},\n  }, nil)\n  _ = pool.Start(context.Background())\n  defer pool.Shutdown(context.Background())\n  var out map[string]any\n  _ = pool.Call(context.Background(), &quot;predict&quot;, map[string]any{&quot;value&quot;: 42}, &amp;out)\n  fmt.Println(out[&quot;result&quot;]) &#x2F;&#x2F; 84\n}\n```<p>*Scope &#x2F; limits*<p>* Same-host&#x2F;pod only (UDS). Linux&#x2F;macOS supported; Windows named pipes not yet.\n* Best for request&#x2F;response payloads ≲ \\~100 KB JSON; GPU orchestration and cross-host serving are out of scope.<p>*Benchmarks (indicative)*<p>* Local M1, simple JSON: \\~*45µs p50* and *\\~200k req&#x2F;s* with 8 workers. Your numbers will vary.<p>*What’s included*<p>* Pure Go client (no CGO), Python worker lib, pool, health checks, graceful restarts, and examples.<p>*Docs &amp; code*<p>* README, design&#x2F;ops&#x2F;security docs, pkg.go.dev: [<a href=\"https:&#x2F;&#x2F;github.com&#x2F;YuminosukeSato&#x2F;pyproc\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;YuminosukeSato&#x2F;pyproc</a>](<a href=\"https:&#x2F;&#x2F;github.com&#x2F;YuminosukeSato&#x2F;pyproc\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;YuminosukeSato&#x2F;pyproc</a>)<p>*License*<p>* Apache-2.0. Current release: v0.2.x.<p>*Feedback welcome*<p>* API ergonomics, failure modes under load, and priorities for codecs&#x2F;transports (e.g., Arrow IPC, gRPC-over-UDS).<p>---<p><i>Source for details: project README and docs.</i> ([github.com][1])<p>[1]: <a href=\"https:&#x2F;&#x2F;github.com&#x2F;YuminosukeSato&#x2F;pyproc\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;YuminosukeSato&#x2F;pyproc</a> &quot;GitHub - YuminosukeSato&#x2F;pyproc: Call Python from Go without CGO or microservices - Unix domain socket based IPC for ML inference and data processin&quot;","time":1757995680,"title":"Show HN: Pyproc – Call Python from Go Without CGO or Microservices","type":"story","url":"https://github.com/YuminosukeSato/pyproc"}