<commit_before># pyringbuf
A python extension implementing a circular/ring buffer of characters as a C extension. I overwrites silently.

##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 
    ''<commit_msg>Felshes out README.md (Fixes #1)<commit_after># pyringbuf
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/Ring-Buffer,
or via "pip install Ring-Buffer". As this is a C extensions, 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 instatiation 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 read the read
index, then the buffer is silently overwritten.
{'fraction_non_alphanumeric': 0.08973128598848369, 'fraction_numerical': 0.0047984644913627635, 'mean_word_length': 2.941398865784499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5637085', 'n_tokens_mistral': 580, 'n_tokens_neox': 559, 'n_words': 264}