cobs
Consistent Overhead Byte Stuffing (COBS)
What it is and what it does
COBS is a byte-stuffing algorithm that encodes arbitrary binary data into a form containing no zero bytes (0x00), enabling zero bytes to serve as reliable packet delimiters in serial and network protocols. The package provides both basic COBS and COBS/R (a variant that reduces overhead) via Python modules with encode and decode functions. It includes a C extension for performance and a pure Python fallback for portability.
The encoding adds predictable overhead: always 1 byte plus potentially n/254 additional bytes for longer packets. This is more efficient than escape-based methods like PPP, which can double packet size in worst cases. The package accepts any buffer-protocol-compatible input (bytes, bytearray) and returns encoded/decoded bytes; framing (adding or stripping delimiter bytes) is left to the application.
Use it for:
- Implement packet framing in serial communication protocols where zero bytes mark packet boundaries.
- Encode binary data for transmission over channels that cannot safely transmit zero bytes.
- Reduce packet size overhead compared to escape-based byte stuffing in bandwidth-constrained protocols.
- Use COBS/R variant to minimize encoding overhead for small message payloads in embedded systems.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Encodes and decodes data using Consistent Overhead Byte Stuffing (COBS), a method that eliminates zero bytes from encoded packets to enable reliable packet framing in communication protocols.
Yes. COBS is a well-established, stable algorithm with a mature implementation (Production/Stable, MIT license). Install it if you need reliable packet framing in serial/network protocols or must eliminate zero bytes from binary data. Medium install friction is acceptable given the C extension fallback. No known vulnerabilities.
Install
cobs on PyPI
pip
pip install cobsuv
uv add cobspoetry
poetry add cobsInstalling cobs
Before you install
Medium install friction due to C extension compilation; pure Python fallback available. Package is stable (Production/Stable status) and actively maintained with recent release (2025-07-20), though maintenance cadence is aging.
License in practice
MIT license (permissive) allows unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects.
Quickstart
pip install cobs
from cobs import cobs
encoded = cobs.encode(b'Hello world\x00This is a test')
decoded = cobs.decode(encoded)
Requires Python >= 3.6; C extension compilation may fail on some platforms, but pure Python implementation is available as fallback.
Verify before relying
- Performance characteristics of C extension vs. pure Python implementation for typical packet sizes.
- Whether the package handles edge cases like empty input or maximum-length packets as documented.
Package facts
| License | ---------------------------------------------------------------------------- Copyright (c) 2010 Craig McQueen Permission is hereby granted, free of charge, to any person obtaining a copy of this… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 390 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 119,210/month — #12,083 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cobs-1.2.2-cp312-cp312-win32.whl; cobs-1.2.2-cp312-cp312-win_amd64.whl; cobs-1.2.2-cp313-cp313-win32.whl; cobs-1.2.2-cp313-cp313-win_amd64.whl; cobs-1.2.2-cp314-cp314-win32.whl; cobs-1.2.2-cp314-cp314-win_amd64.whl
Keywords: byte, stuffing
Tags
More Communications packages
Pyasn1 encodes and decodes ASN.1 data…
permissive · top 100 on PyPI
pyasn1-modulesProvides a collection of ASN.1 data structures…
permissive · top 100 on PyPI
kombuKombu is a messaging library that provides a…
permissive · top 1,000 on PyPI
humanfriendlyFormats and parses numbers, file sizes,…
permissive · top 1,000 on PyPI
coloredlogsAdds colored output to Python's standard…
permissive · top 1,000 on PyPI
aiosmtplibaiosmtplib is an asynchronous SMTP client that…
permissive · top 5,000 on PyPI
scalecodecEncodes and decodes data using the SCALE codec,…
permissive · top 15,000 on PyPI
spacepacketsImplements CCSDS and ECSS packet standards for…
permissive · top 15,000 on PyPI
simplefixSimplefix provides a lightweight FIX (Financial…
permissive · top 15,000 on PyPI
bbpbDecode and re-encode Protocol Buffer messages…
permissive · top 15,000 on PyPI
canoserCanoser implements canonical serialization for…
permissive · top 15,000 on PyPI
mbstrdecoderDecodes multi-byte character strings by…
permissive · top 5,000 on PyPI
xmhuffmanDecodes canonical-Huffman compressed string…
permissive · top 15,000 on PyPI
reedsoloEncodes and decodes data using Reed-Solomon…
permissive · top 5,000 on PyPI
bytesparseProvides a bytearray-like class that stores…
permissive · top 15,000 on PyPI
pyiso8583Serializes and deserializes ISO8583 financial…
permissive · top 15,000 on PyPI