An analogue of Struct for python!!
Installing:
pip install gpack
Example usage:
import gpack
gpack.setup()
"1234".pack("bi",2)
GPack replaces the python compiler for improved and convenient operation.
b - Big-Endian
l - Little-Endian
i - Int
I - Signed Int
s - String
o - Bool
n - Bytes
> - Big-endian
< - Little-endian
More usage:
test_data = [123, -123, "aboba", b"aboba", 1234, True, False, 321]
import gpack
gpack.setup()
packed = test_data.pack("bilIsniooi", 1, 1, 5, 10, 5, 1, 1, 2)
unpacked = packed.unpack("bi lI s n i o o i", 1, 1, 5, 10, 5, 1, 1, 2)
print(unpacked)
[123, -123, 'aboba', b'aboba\x00\x00\x00\x00\x00', 1234, True, False, 321]
You can use the spaces for ease of use
Format Specifiers with sizes
Numbers after formats specify sizes in bytes:
# Pack string (5 bytes) + int (4 bytes) + bool (1 byte)
packed = ["hello", 123, True].pack("s i o", 5, 4, 1)
# Unpack with same sizes
unpacked = packed.unpack("s i o", 5, 4, 1)
Also you can use without setup:
import gpack
gpack.pack([123],'i',1)
gpack.unpack(b'}','i',1)
You can use size inside arg 1:
import gpack
gpack.setup()
[123].pack("1i") # Pack 123 with unsinged int and size 1
[123].pack("i",1) # Pack 123 with unsinged int and size 1
To use from libs remove "gpack.setup()"
In latest version:
Fixed some bugs
Metadata
Release files for gpack 0.2.3
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 | Actions |
|---|---|---|---|---|
| gpack-0.2.3.tar.gz | 10.8 kB | Without provenance | Details for gpack-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gpack-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for gpack-0.2.3-py3-none-any.whl |
Total release size: 21.1 kB
Release files / gpack-0.2.3.tar.gz
| Download URL | gpack-0.2.3.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
533d8c73c59aece6815534722042ba9b756cf07ec785871da0d13200bec81688
|
|
BLAKE2b-256 checksum How to use checksums |
3de336f33d827ea98d0f05dc0a7efc294e6efbc3efe2a5365f3bedfab209a9dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / gpack-0.2.3-py3-none-any.whl
| Download URL | gpack-0.2.3-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43ccacf18597343e3cb3235af19704315352a398376d2db4f3b450569bb2580f
|
|
BLAKE2b-256 checksum How to use checksums |
b76c7a5f0bee33d3d0a3987a7dd2461280ab0aef0a3cd09f54b71328893fa4a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for gpack 0.2.3
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.