Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

A python extension implementing a circular/ring buffer of characters as a C extension. It overwrites silently.

Availability

Currently, pyringbuf is available at https://pypi.python.org/pypi/pyringbuf, or via pip install pyringbuf. As this is a C extension, there is a compilation step, so your system will need to be able to compile extension modules for python.

Usage

>>> from ringbuf import RingBuffer
>>> R = RingBuffer(5)    #choose your buffer size
>>> R.push("a")          #push a single character into the buffer
>>> R.pop()              #pop a single character
'a'
>>> R.write("bcdef")     #fill buffer with many characters at once
>>> R.read(4)            #read many characters at once
'bcde'
>>> R.read(1)
'f'
>>> R.read(1)            #returns an empty string if the buffer is empty
''

Implementation

For the interested, this has been implemented as a pure C extension. The ring buffer itself is implemented as a fixed length array of chars (8-bit signed), dynamically allocated on the Python Heap on instantiation of a buffer. Read and write indexes both increase monotonically, and addresses in the array are determined using index % (modulo) buffer size. Writing more than the buffer size at once throws an exception, otherwise if writing overtakes the read index in the modulo space the buffer contents are silently overwritten.

Release files for pyringbuf 0.1b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyringbuf 0.1b2
File Size Uploaded
pyringbuf-0.1b2.tar.gz 3.7 kB Details

Release files / pyringbuf-0.1b2.tar.gz

Download URL pyringbuf-0.1b2.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a93f14be50f0b5320bc6a2281ee2c4f2193171aef7be14dbe5635bbc84aa98fb
BLAKE2b-256 checksum
How to use checksums
1413c1f4a8442b8f01383dd7dabd1f3bc41ab6aa1df4fcacf5f9fee25dad40a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1b2 This release

1 release file

0.1b0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page