# Python and Go : Part IV - Using Python in Memory

DevFeed: [Python and Go : Part IV - Using Python in Memory](<https://devfeed.tech/articles/python-and-go-part-iv-using-python-in-memory-22171.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2020/09/using-python-memory.html>)

Published: 2020-09-15T00:00:00Z

Content type: article

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Python](<https://devfeed.tech/topics/python.md>), [gRPC](<https://devfeed.tech/topics/grpc.md>), [Code](<https://devfeed.tech/topics/code.md>), [Network](<https://devfeed.tech/topics/network.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [blog](<https://devfeed.tech/tags/blog.md>), [code](<https://devfeed.tech/tags/code.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [memory](<https://devfeed.tech/tags/memory.md>), [network](<https://devfeed.tech/tags/network.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

This tutorial explains how to call Python from Go using cgo and Python as a shared library, reducing the networking and serialization overhead associated with gRPC. It introduces relevant CPython internals and describes sharing memory between the two runtimes while managing object ownership and reference counting.

## Source excerpt

Series Index Python and Go: Part I - gRPC Python and Go: Part II - Extending Python With Go Python and Go: Part III - Packaging Python Code Python and Go: Part IV - Using Python in Memory Introduction In a previous post we used gRPC to call Python code from Go. gRPC is a great framework, but there is a performance cost to it. Every function call needs to marshal the arguments using protobuf, make a network call over HTTP/2, and then un-marshal the result using protobuf.