{"id":27240,"library":"plum-py","title":"plum-py","description":"Pack/Unpack Memory. A Python library for packing and unpacking binary data structures, similar to struct but with higher-level features. Current version 0.8.7, release cadence is low (last release August 2022).","status":"active","version":"0.8.7","language":"python","source_language":"en","source_url":"https://github.com/niccokunzmann/plum-py","tags":["binary","pack","unpack","struct"],"install":[{"cmd":"pip install plum-py","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Package name is plum, not plum-py.","wrong":"from plum_py import Struct","symbol":"Struct","correct":"from plum import Struct"}],"quickstart":{"code":"from plum import Struct\n\nclass MyHeader(Struct):\n    magic: 'I'  # unsigned int\n    length: 'I'\n    data: 'I'\n\nhdr = MyHeader(magic=0x1234, length=100, data=0)\nbuffer = hdr.pack()\nprint(buffer.hex())\n","lang":"python","description":"Define a struct with fields and pack into bytes."},"warnings":[{"fix":"Use 'from plum import Struct'.","message":"The import is 'from plum import Struct', not 'plum-py' or 'plum_py'. The PyPI name is plum-py but the module name is plum.","severity":"gotcha","affected_versions":"all"},{"fix":"Define fields as class-level annotations with format strings, e.g., field_name: 'I'.","message":"Field types are specified as strings (e.g., 'I' for unsigned int) similar to struct module. Using Python type hints does not work; you must use struct format characters.","severity":"gotcha","affected_versions":"all"},{"fix":"For complex structures, consider using construct or raw struct.","message":"The Struct class does not support variable-length arrays or nested structs directly. Use custom pack/unpack methods.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'import plum' or 'from plum import Struct'.","cause":"Trying to import with the PyPI package name instead of the module name.","error":"ImportError: No module named 'plum_py'"},{"fix":"Ensure field names match class attributes defined with format strings.","cause":"Attempting to set fields via constructor with Python-typed field names, but the library expects specific names derived from format strings.","error":"TypeError: __init__() got an unexpected keyword argument 'field_name'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}