Skip to main content

A bytes manipulation library inspired by Java ByteBuffer

Project description

PyByteBuffer

A library to manipulate buffers inspired by Java nio ByteBuffer

>> DOCUMENTATION

Setup

pip3 install PyByteBuffer

Usage

from PyByteBuffer import ByteBuffer

buf = ByteBuffer.allocate(50)
# write byte 0x10 and increment position by 1
buf.put(0x10)
buf.put([0xcc, 0xdd, 0xee])
buf.put('something')
buf.put(bytes([00] * 4))

# endianness
buf.put(123456, 'little')
buf.put(1234561434234234, 'big')

# read 1 byte and increment position by 1
value = buf.get(1)
# read 10 bytes little endian and increment position by 10
value = buf.get(10, 'little')

# other allocations
buf = ByteBuffer.from_hex('deadbeef')
buf = ByteBuffer.wrap(bytes())

About performances

The performance analysis we can do in this library is all around the conversion between int->bytes bytes<-int.

Tested with a cycle of 1/100/500/1000 conversion using python3 builtin api int.to_bytes/from_bytes, struct pack/unpack and a "primitive" solution posted in stackoverflow

Project details


Download files

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

Source Distribution

PyByteBuffer-1.0.5.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

PyByteBuffer-1.0.5-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file PyByteBuffer-1.0.5.tar.gz.

File metadata

  • Download URL: PyByteBuffer-1.0.5.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for PyByteBuffer-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5aa1e83c28bf5570d09bae0913937514325a7239e818220506baff8a8c0b51f9
MD5 cd1b42b14714635c0422ed34c01e1b3f
BLAKE2b-256 2207124736940ea5c8526c0e33c241fb25fce5b154e5481b243db50be42f7c3b

See more details on using hashes here.

File details

Details for the file PyByteBuffer-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: PyByteBuffer-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for PyByteBuffer-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a6332b48b9a2101bbaeeda086586f214407b7c66bca55210520ee3ac4292d2f0
MD5 4809c303f00d13846e78fd39ce9ee815
BLAKE2b-256 53bb95539135ad829e93bb1f20bf1d43de8139b009668c672e0b33d8e91f39aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page