Installation

Using

fromcircularbufferimportCircularBufferbuf=CircularBuffer(1024)buf.write(b'some text')whilelen(buf)>0:buf.read(1)fromreimportmatchbuf.write(b'hallo')# python2withbuf:match_found=match(br'^ha',buf)# python3match_found=match(br'^ha',buf)# use `result` immediately because regex didn't make memory copy of the# internal buffer, or run another `match()` on a memory copy, for example:match_found_str=buf.read(len(match_found.group(0)))independent_match_found=match(br'^ha',match_found_str)