Skip to main content

Pak

GitHub Workflow Status Read the Docs Codecov License Python Version Support

Pak is a simple, yet powerful and extendable Python library for translating between raw data and usable, meaningful values.

Here's an example of simple usage:

import pak

raw_data = (
    # Represents the value '0'.
    b"\x00" +

    # A string encoded in 4 bytes, with characters "abcd".
    b"\x04" + b"abcd" +

    # Two contiguous 16-bit, little-endian numbers, '1' and '2'.
    b"\x01\x00" + b"\x02\x00"
)

class MyPacket(pak.Packet):
    byte:   pak.Int8
    string: pak.PrefixedString(pak.UInt8)
    array:  pak.UInt16[2]

# Unpack a packet from the raw data.
packet = MyPacket.unpack(raw_data)

# Each field will have the appropriate value unpacked from the raw data.
assert packet == MyPacket(
    byte   = 0,
    string = "abcd",
    array  = [1, 2],
)

# Pack the packet into raw data.
packet_data = packet.pack()

# The packed data will be the same as the initial raw data.
assert packet_data == raw_data

Features

  • A declarative, simple API for defining packet structures.
  • Highly generic, able to fit any packet protocol with relative ease.
  • The ability to define your own means of marshaling between raw data and usable values.
  • A composable API to allow you to easily leverage pre-existing code and reduce code duplication.
  • A healthy set of provided features with general application, such as marshaling numeric, string, and enum values.
  • Numerous high quality tests to make sure your code works as expected.
  • Well-documented to help you know what APIs exist and how to use them.
  • And more!

Installation

To install Pak, simply install through pip:

$ pip install pak

Documentation

The documentation for Pak lives at https://pak.readthedocs.io. There you will find tutorials, including a quickstart, and a reference manual detailing the API that Pak provides.

Goals

The impetus for creating this library was that I was making a library for the Minecraft networking protocol, which had a very similar API to the one now in Pak. I then wanted to write code for other protocols, and found myself duplicating much of the code I had written for Minecraft's protocol. I therefore created this library so that I did not need to repeat myself for each and every protocol I wrote code for. And so, from that inciting motivation, these are Pak's goals:

  • Above all else, maintain a pleasing and readable API.
  • Be easily workable with many if not all packet protocols.
  • Have a solid base of fundamental or generally applicable features.
  • Be easily extendable to account for all the quirks a particular protocol might have.
  • Be a venue for me to learn about API design and project maintenance.

In particular Pak's goals do not include performance. I have not benchmarked the library, and I don't currently intend to go through and make sure all code is optimized, though I of course make no conscious effort to pessimize code either. I may in the future go through and improve the performance of particular features, but in general performance is not something in particular that I strive for.

Credits

Release files for pak 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pak 1.1.2
File Size Uploaded
pak-1.1.2.tar.gz 57.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pak 1.1.2
File Interpreter ABI Platform
pak-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 123.6 kB

Release files / pak-1.1.2.tar.gz

Download URL pak-1.1.2.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
16f6b69dafa2c4a28824081e0948d9d4d9ef7567bdada10655667a94689306de
BLAKE2b-256 checksum
How to use checksums
0045e93dfdfc248809f5ec5b9d8bda1f14a8a2f5c8b69c348bd40339fcecb15f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release files / pak-1.1.2-py3-none-any.whl

Download URL pak-1.1.2-py3-none-any.whl
Size 65.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5203c0eb2ef11b088a900dd62d2b8e3cddd33704817e2fcea9ea0695d3e56896
BLAKE2b-256 checksum
How to use checksums
1829992a2f6d7e76002aad025fb267ff643ac97b79f9c00dfaea8fae6e85acaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page