{"id":5132,"library":"binapy","title":"Binapy: Binary Data Manipulation","description":"BinaPy is a Python module that simplifies binary data manipulation, offering a fluent interface for encoding, decoding, compressing, decompressing, and hashing data in various formats. It aims to provide a more human-friendly alternative to Python's standard library for these tasks. The library maintains an active release cadence, with version 0.8.0 released in January 2024.","status":"active","version":"0.8.0","language":"en","source_language":"en","source_url":"https://github.com/guillp/binapy","tags":["binary data","data manipulation","encoding","decoding","hashing","compression","serialization"],"install":[{"cmd":"pip install binapy","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"BinaPy","correct":"from binapy import BinaPy"}],"quickstart":{"code":"from binapy import BinaPy\n\n# Encode and compress data fluently\nbp = BinaPy(\"Hello, World!\").to(\"deflate\").to(\"b64u\")\nprint(f\"Encoded and compressed: {bp}\")\n\n# Decode and decompress back\noriginal_data = bp.decode_from(\"b64u\").decode_from(\"deflate\").ascii()\nprint(f\"Decoded and decompressed: {original_data}\")\n\n# BinaPy objects are bytes subclasses\nprint(f\"Is BinaPy instance a bytes object? {isinstance(bp, bytes)}\")","lang":"python","description":"Initialize a BinaPy object with string or bytes data, then chain method calls for transformations like compression (deflate) and encoding (base64url). The object can then be decoded back in reverse order of operations. BinaPy instances are subclasses of `bytes`."},"warnings":[{"fix":"Update method calls from `serialize_from()` to `serialize_to()` and `parse_to()` to `parse_from()`.","message":"In version 0.3.0, the methods for serialization and parsing were renamed. `serialize_from()` became `serialize_to()`, and `parse_to()` became `parse_from()`.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Manually convert epoch timestamps back to `datetime` objects after parsing JSON data if `datetime` instances are expected.","message":"When serializing JSON, `datetime` instances are converted to epoch timestamps. However, there is no automatic conversion back from epoch timestamps to `datetime` objects when parsing JSON.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Be aware that `isinstance(binapy_obj, bytes)` will return `True`. If strict type distinction is required, consider explicit checks or conversions.","message":"BinaPy objects are subclasses of `bytes`. While this allows seamless integration with functions expecting `bytes`, unexpected behavior might occur if type-checking specifically for `BinaPy` and not `bytes`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}