Skip to content

A simple example of passing a pointer to numpy array to go (golang) code.

License

Notifications You must be signed in to change notification settings

ryanbressler/numpy2go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

numpy2go

This is a simple example of how to write a go libary (shared object) with exported functions that can accept numpy arrays as passed by ctypes. It requires go 1.5.

To try it run:

go build -buildmode=c-shared -o numpy2go.so
python numpy2go.py

Which should output:

Python says [ 0.  1.  2.]
Go says [0 1 2]

The code is based on these two sources:

https://scipy-lectures.github.io/advanced/interfacing_with_c/interfacing_with_c.html#id5

https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices

About

A simple example of passing a pointer to numpy array to go (golang) code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published