Skip to main content

More efficiently match bytes using memoryviews to prevent copying

Project description

Buffer matchers, as I refer to them, are wrappers around bytes that allow easier, more memory-efficient reading and pattern matching

These are used in my programming language Caustic's Lexer

Beyond base classes, this package provides two buffer matcher classes:

  • DynamicBufferMatcher / dynamic.BufferMatcher
  • StaticBufferMatcher / static.BufferMatcher

The buffer classes shown above can be .read(), .seek()ed through, and .match()ed against strings, callables, or regular expressions

The "dynamic" and "static" in the names refer to how they calculate line and column numbers -- namely, the "dynamic" buffer matcher calculates line and column numbers via properties, every time they are accessed; whilst the "static" buffer matcher calculates line and column numbers only when the position of the matcher is changed. "Dynamic" buffer matchers are recommended if line and column numbers are accessed less often than the position is changed, and vice-versa for "static" buffers.

Changelog

v0.1.1

  • Fixed SimpleBufferMatcher.copy_peek() ignoring size parameter

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

buffer-matcher-0.1.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

buffer_matcher-0.1.1-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

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