Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Binary Data for Humans

Project Description

Bitstream

A Python library to manage binary data as bitstreams.

Overview

Bitstream three main features:

  • It is easy to use since the bitstream abstraction is simple.
  • It works seamlesly at the bit and byte level.
  • It supports Python, NumPy and user-defined types.

See the documentation Overview section for more details.

Quickstart

Make sure that Python 2.7 is installed and that pip, NumPy and a C compiler are available, then install bitstream with

$ pip install bitstream

For more details, refer to the documentation.

Examples

First, the mandatory “Hello World!” example:

>>> from bitstream import BitStream
>>> BitStream("Hello World!")
010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001

The basic API is made of three methods only:

  • stream = BitStream() to create an empty stream.
  • stream.write(data, type) to write data data of type type.
  • data = stream.read(type, n) to read n items of type type.

For example:

>>> stream = BitStream()      # <empty>
>>> stream.write(True, bool)  # 1
>>> stream.write(False, bool) # 10
>>> from numpy import int8
>>> stream.write(-128, int8)  # 1010000000
>>> stream.write("AB", str)   # 10100000000100000101000010
>>> stream.read(bool, 2)      # 100000000100000101000010
[True, False]
>>> stream.read(int8, 1)      # 0100000101000010
array([-128], dtype=int8)
>>> stream.read(str, 2)       # <empty>
"AB"

Refer to the documentation Overview section for more elementary examples.

Contributing

Refer to Contributing in the documentation.

License

Bitstream is open source software released under the MIT license.

Copyright (c) 2012-2017 Sébastien Boisgérault

Release History

Release History

This version
History Node

2.2.0

History Node

2.0.3

History Node

2.0.3-alpha.4

History Node

2.0.3-alpha.3

History Node

2.0.3-alpha.2

History Node

2.0.3-alpha.1

History Node

2.0.2

History Node

2.0.1

History Node

2.0.0

History Node

2.0.0-alpha.4

History Node

2.0.0-alpha.3

History Node

2.0.0-alpha.2

History Node

1.0.4

History Node

1.0.4-alpha.1

History Node

1.0.3

History Node

1.0.2

History Node

1.0.2-alpha.1

History Node

1.0.1

History Node

1.0.0

History Node

1.0.0-alpha.17

History Node

1.0.0-alpha.16

History Node

1.0.0-alpha.15

History Node

1.0.0-alpha.14

History Node

1.0.0-alpha.13

History Node

1.0.0-alpha.12

History Node

1.0.0-alpha.11

History Node

1.0.0-alpha.10

History Node

1.0.0-alpha.9

History Node

1.0.0-alpha.8

History Node

1.0.0-alpha.7

History Node

1.0.0-alpha.6

History Node

1.0.0-alpha.5

History Node

1.0.0-alpha.4

History Node

1.0.0-alpha.3

History Node

1.0.0-alpha.2

History Node

1.0.0-alpha.1

History Node

0.0.0.dev

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
bitstream-2.2.0.tar.gz (166.6 kB) Copy SHA256 Checksum SHA256 Source Nov 15, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting