Registry / serialization / cobs
library1.2.2pypypi✓ verified 87d ago

Consistent Overhead Byte Stuffing (COBS) implementation for Python. Encodes arbitrary binary data into a form that removes any occurrence of a specific delimiter byte (typically 0x00), with minimal overhead. Current version 1.2.2 supports Python >=3.6. Development is stable with infrequent releases.

pip install cobs
INSTALL
IMPORT
SIG · COBS
C
cobs
serializationpythonv1.2.2
Install
3.2s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.2s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cobs
import cobs.cobs as cobs
import cobs
cobs package has submodules; 'import cobs' only imports the package, not the cobs.encode/decode functions.
cobsr
import cobs.cobsr as cobsr
from cobs import cobsr
cobsr is a submodule; use 'cobs.cobsr' for clarity.

Encode and decode data using COBS. The delimiter byte (0x00) is removed from the encoded output.

import cobs.cobs as cobs data = b'\x00\x01\x02\x00\x03' encoded = cobs.encode(data) print('Encoded:', list(encoded)) decoded = cobs.decode(encoded) print('Decoded:', list(decoded))
Debug
Known issues
deprecatedCOBSR (reducing overhead variant) module cobs.cobsr is less tested and may have edge cases.
fix
Use cobs.cobs for compatibility unless you specifically need reduced overhead.
affects: all
gotchaThe encode() function does NOT add a trailing delimiter byte. You must add it yourself if your protocol expects it.
fix
encoded = cobs.encode(data) + b'\x00'
affects: all
gotchaThe decode() function expects the encoded data to NOT contain the delimiter byte (except possibly the final byte). Incorrectly encoded data may raise ValueError.
fix
Ensure your encoded data does not include delimiter bytes (except the optional trailing delimiter).
affects: all
Errors
Common errors & fixes
AttributeError: module 'cobs' has no attribute 'encode'
Imported cobs package instead of cobs.cobs submodule.
fix
Change to 'import cobs.cobs as cobs' or 'from cobs import cobs'
ValueError: decoded data contains unexpected zero byte
Encoded data includes a delimiter byte (0x00) that is not the final byte, or the decoder was given raw data.
fix
Ensure you pass properly COBS-encoded data. Use cobs.encode() to encode before transmission.
cobs.decode() returns empty bytes when input contains only a trailing zero
A single 0x00 byte decodes to an empty byte string (valid COBS). This might be unexpected.
fix
Check for empty decoded output if protocol expects non-empty data.
Upgrade
Version history
1.2.2latest on PyPI · released Jul 20, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cobs — pip install cobs · libregistry