skillfed

cobs

Consistent Overhead Byte Stuffing (COBS)

cobs v1.2.2 119.2K downloads/30d#12,083 on PyPI50
Permissive 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) AGING released

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 cobs

uv

uv add cobs

poetry

poetry add cobs

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Topic :: Communications

Tags

byte stuffing encodingcobs packet framingzero byte eliminationserial protocol encodingpacket boundary delimitercommunication protocol encodingcobs/r reduced overhead
packet-framingserial-protocolbyte-encoding

More Communications packages