{"id":9080,"library":"listcrunch","title":"listcrunch","description":"listcrunch is a Python utility library (current version 1.0.1) that provides a simple, human-readable way to compress redundant sequential data within lists into a string format, and to decompress it back. It is a stable, focused library with no active new feature development since its last release in 2020.","status":"active","version":"1.0.1","language":"en","source_language":"en","source_url":"https://github.com/MuckRock/listcrunch","tags":["data compression","list","sequence","utility","human-readable","lossless"],"install":[{"cmd":"pip install listcrunch","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"crunch","correct":"from listcrunch import crunch"},{"symbol":"uncrunch","correct":"from listcrunch import uncrunch"}],"quickstart":{"code":"from listcrunch import crunch, uncrunch\n\n# Example data\ndata = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 1]\n\n# Compress the data\ncompressed_string = crunch(data)\nprint(f\"Original: {data}\")\nprint(f\"Compressed: {compressed_string}\")\n# Expected output: Original: [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 1]\n# Expected output: Compressed: 1:0-8;2:9-10;3:11-13;1:14\n\n# Uncompress the data\ndecompressed_list = uncrunch(compressed_string)\nprint(f\"Decompressed: {decompressed_list}\")\n# Expected output: Decompressed: [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 1]\n\n# Verify round trip\nassert data == decompressed_list","lang":"python","description":"This quickstart demonstrates how to use the `crunch` function to compress a list of sequential, redundant data into a human-readable string format, and then use the `uncrunch` function to restore the original list. The output format `VALUE:START-END;...` indicates that 'VALUE' appears from 'START' index to 'END' index (inclusive) in the original list."},"warnings":[{"fix":"Ensure input to `crunch` is a list of hashable elements where sequential compression makes sense. For lists of unhashable objects, you might need to process them into a hashable representation first.","message":"The `crunch` function is designed for lists of hashable items where sequential redundancy is meaningful. Providing non-list iterables or complex, unhashable objects might lead to unexpected behavior or errors (e.g., `TypeError` for unhashable types if the internal mechanism attempts hashing).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use the `uncrunch` function for decompression to ensure forward compatibility and robust parsing of the compressed format.","message":"While the compressed string format (e.g., `1:0-8;2:9`) is human-readable, directly parsing this string format in your application logic, rather than using the `uncrunch` function, can lead to brittle code. Future (though unlikely) changes to the internal string representation could break such custom parsers.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If encountering unexpected behavior with very old or new Python versions, test within a Python 3.7+ environment. Report any compatibility issues to the library's GitHub repository.","message":"The library was last updated and tested against Python 3.7.6. While it is `py3-none-any` (Python 3 compatible), very old Python 3 versions (e.g., <3.6) or potential future major Python releases might introduce subtle incompatibilities. No known issues currently exist.","severity":"gotcha","affected_versions":"<1.0.1"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install listcrunch` in your terminal to install the library.","cause":"The `listcrunch` library has not been installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'listcrunch'"},{"fix":"Ensure you are importing the functions correctly using `from listcrunch import crunch, uncrunch` and that no other variables in your scope share these names.","cause":"This usually happens if you've accidentally defined a local variable named `crunch` or `uncrunch` that overwrites the imported function, or if you tried `import listcrunch` and then called `listcrunch.crunch()` directly, which is incorrect as `crunch` is directly imported from the module.","error":"TypeError: 'str' object is not callable (when calling crunch or uncrunch)"},{"fix":"Verify that the string passed to `uncrunch` was either originally produced by the `crunch` function or meticulously follows its specified format.","cause":"The string provided to the `uncrunch` function does not conform to the expected `VALUE:START-END;...` format generated by `listcrunch`.","error":"ValueError: Invalid compressed string format (when calling uncrunch)"}]}