go4py: ⚡ Supercharge your Python with Go ⚡
Do you ever wish Python were faster? go4py is here to help!
Enjoy the speed and simplicity of Go within Python! You can write bottlenecks of your Python code as CGo functions. The go4py will automatically generate a Python module from it for you!
Check the performance boost in our benchmarks and get a sense of how much faster it can be compared to basic Python! 🚀
Installation
Linux
- Install Go
pip install go4py
Windows
- Install Go
- Install MSYS2 and then install mingw-toolchain inside it.
- Install
go4pyin a python vitrual exnvironment. - Open a mingw shell and activate the venv inside it (e.g.
source venv/Scripts/activate) - Add Go to your PATH in the mingw shell (e.g.,
export PATH=$PATH:"/c/Program Files/Go/bin/")
Usage
To create a Go package inside your Python project:
go4py init <module_name>
This will create a directory with the name <module_name> and add go.mod to your project.
You can go to <module_name>/src directory and add your Go functions there.
To build the Go package and generate bindings code for the Python module:
go4py build <module_name>
You can now import the functions as methods of a python module:
from <module_name> import <function_name>
Please note that we convert the function names' first character to lower case.
How it works
There is a Makefile in the created directory with four major steps:
- Parsing the Go code and extracting the signatures of the functions (the
functions.jsonfile). - Building an object file from Go code (
.aand.hfiles). - Making a C wrapper for the Go functions as a Python native C extension.
- Building a shared library from the generated C code (
__init__.sofile or__init__.pydfile).
The Makefile is actually quite readable, and you can modify it to your needs go4py will just run it
Documentation
This documentation will explain how to use go4py. there is also a examples directory for some examples. But if you need to dive into inner-workings of go4py take a look at the tests directory and checkout the codes that go4py generates automaticly from a go function signature.
Metadata
Release files for go4py 0.1.74
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| go4py-0.1.74.tar.gz | 20.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| go4py-0.1.74-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.0 kB
Release files / go4py-0.1.74.tar.gz
| Download URL | go4py-0.1.74.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08c7baec54b92fd8e915093a3a9bf900abcc121fed5d53caeff35183c7fc5276
|
|
BLAKE2b-256 checksum How to use checksums |
1819d1b0af496fb5980037c0d24474e877610a94869bf3393b7c64d1837966ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Release files / go4py-0.1.74-py3-none-any.whl
| Download URL | go4py-0.1.74-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f37baa374b1be9bcc4236ba3ad9e0c10336c75d33bc320192a9c4a6edab4d94
|
|
BLAKE2b-256 checksum How to use checksums |
b598ae2bd5027da4236d97976f54e7547b56f230b11b45164301f0079656a015
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.13
|
Security for go4py 0.1.74
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.