{"id":9658,"library":"dissect-util","title":"Dissect Utilities (dissect-util)","description":"Dissect.util (dissect-util on PyPI) is a module within the Dissect forensics framework, providing a collection of essential utility functions. It offers functionalities for humanizing data (e.g., bytes, time), robust JSON serialization and deserialization, typecasting, progress bars, and packaging introspection. It is currently at version 3.24 and receives regular updates as part of the broader Dissect project.","status":"active","version":"3.24","language":"en","source_language":"en","source_url":"https://github.com/fox-it/dissect.util","tags":["utility","forensics","data-processing","helper","humanize","json"],"install":[{"cmd":"pip install dissect-util","lang":"bash","label":"Standard installation"},{"cmd":"pip install dissect-util[msgspec]","lang":"bash","label":"With optional msgspec JSON backend"}],"dependencies":[{"reason":"Optional dependency for faster JSON serialization/deserialization. Enabled via 'msgspec' extra.","package":"msgspec","optional":true}],"imports":[{"symbol":"bytes_to_human","correct":"from dissect.util.humanize import bytes_to_human"},{"symbol":"ProgressBar","correct":"from dissect.util.progressbar import ProgressBar"},{"note":"Functions are typically imported directly from submodules, not accessed via top-level `dissect.util.json.serialize`.","wrong":"import dissect.util.json","symbol":"serialize","correct":"from dissect.util.json import serialize"}],"quickstart":{"code":"from dissect.util.humanize import bytes_to_human, time_to_human\nfrom dissect.util.progressbar import ProgressBar\nimport time\n\nprint(f\"Humanized bytes: {bytes_to_human(1_234_567_890)}\")\nprint(f\"Humanized time: {time_to_human(3600 * 24 * 7 * 3 + 12345)}\")\n\n# Example of using a progress bar\nprint(\"\\nDemonstrating ProgressBar:\")\nwith ProgressBar(total=10) as bar:\n    for i in range(10):\n        time.sleep(0.1) # Simulate work\n        bar.next()\nprint(\"Progress bar complete!\")","lang":"python","description":"This quickstart demonstrates common utility functions from `dissect.util`, including humanizing byte and time values, and using a simple console progress bar."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer, or pin your dissect-util dependency to <3.0.0 if compatible with other project requirements.","message":"dissect-util version 3.0.0 and later requires Python 3.10 or higher. Earlier versions supported Python 3.8+.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"For `enum`, update imports from `from dissect.util.enum import ...` to `from dissect.enum import ...`. For `structures`, refactor your code as the module has no direct replacement in `dissect.util`.","message":"The `dissect.util.enum` module was moved to `dissect.enum` in version 3.0.0, and `dissect.util.structures` was entirely removed. Code relying on these modules will break.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Install `dissect-util` with the `msgspec` extra: `pip install dissect-util[msgspec]`.","message":"Advanced JSON features, such as `msgspec` backend support for faster serialization/deserialization, require installing the `msgspec` optional dependency.","severity":"gotcha","affected_versions":">=3.20.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"The module was moved. Update your import to `from dissect.enum import ...`.","cause":"Attempting to import from the old `dissect.util.enum` path after upgrading to dissect-util 3.x.","error":"ModuleNotFoundError: No module named 'dissect.util.enum'"},{"fix":"The `dissect.util.structures` module was removed in version 3.0.0. You will need to refactor your code to use alternative data structures or utilities.","cause":"Attempting to use `dissect.util.structures` after upgrading to dissect-util 3.x.","error":"AttributeError: module 'dissect.util' has no attribute 'structures'"},{"fix":"dissect-util >=3.0.0 requires Python 3.10 or higher. Upgrade your Python environment.","cause":"Running dissect-util 3.x on an unsupported Python version (e.g., Python 3.9 or older).","error":"SyntaxError: future feature annotations is not defined"},{"fix":"Install dissect-util with the `msgspec` extra: `pip install dissect-util[msgspec]`.","cause":"Trying to use `msgspec`-backed JSON functions without installing the optional `msgspec` dependency.","error":"AttributeError: module 'dissect.util.json' has no attribute 'serialize_msgspec'"}]}