Python bytes, bytearray, memoryview, and Binary Data Cheat Sheet
Handle Python binary data safely with bytes, bytearray, memoryview, struct packing, hexadecimal conversion, slicing, and zero-copy buffer techniques.
Open cheat sheetPython · 9 guides
Represent text, numbers, structured data, dates, binary values, and persistent objects.
Focused references
Each guide includes copy-ready syntax, detailed examples, and authoritative references.
Handle Python binary data safely with bytes, bytearray, memoryview, struct packing, hexadecimal conversion, slicing, and zero-copy buffer techniques.
Open cheat sheetModel dates, aware datetimes, UTC instants, parsing, IANA time zones, daylight-saving transitions, ambiguous times, and elapsed durations in Python.
Open cheat sheetHandle Python numeric precision deliberately with float comparisons, math.fsum, Decimal contexts and rounding, Fraction arithmetic, and statistics.
Open cheat sheetExchange JSON and CSV safely in Python with deterministic encoding, custom types, strict numeric parsing, duplicate detection, streams, dialects, and records.
Open cheat sheetPersist trusted Python objects with pickle and shelve using explicit protocols, custom state, persistent IDs, safe inspection, and disciplined compatibility boundaries.
Open cheat sheetGenerate reproducible simulations and summarize numeric data with random, secrets, and statistics while avoiding bias, invalid assumptions, and precision traps.
Open cheat sheetSearch, validate, capture, iterate, split, replace, and debug text with Python's re module, raw strings, named groups, flags, and bounded patterns.
Open cheat sheetHandle Unicode text correctly in Python with UTF-8, normalization, case folding, grapheme-aware design, codec error policies, and explicit file boundaries.
Open cheat sheetParse, query, stream, modify, and generate XML safely with ElementTree, namespaces, incremental parsing, canonicalization, and security boundaries.
Open cheat sheet