Skip to main content

GPack is struct analog and better!

Project description

An analogue of Struct for python and even better!!

Installing:

pip install gpack

Example usage:

import gpack 
"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
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)

In 0.1.2: Fixed some bugs. Added new test scripts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpack-0.1.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gpack-0.1.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file gpack-0.1.2.tar.gz.

File metadata

  • Download URL: gpack-0.1.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for gpack-0.1.2.tar.gz
Algorithm Hash digest
SHA256 37a9a964ef7bb6a890ae56c7490fdf296a5eb2e328016796c865bfb3791b622c
MD5 a8dde86c215ace297ce30f1debd539a0
BLAKE2b-256 78aadcc95616921705e747da133921bdce66c5f405f795133fec19412d6f1fe8

See more details on using hashes here.

File details

Details for the file gpack-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gpack-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for gpack-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 da8566f9618ff16caf480508c4ef1f724872d753c2ed4d79623b725bd8b1ca5d
MD5 eb01ff0ffd475079364a711af2890ff2
BLAKE2b-256 86e7571242573548dcedcc0472d538ce30cda7e243fcb14da78a72bcd3eb8234

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page