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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file buffer-matcher-0.1.1.tar.gz.

File metadata

  • Download URL: buffer-matcher-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for buffer-matcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1b499a7cd1bdec3572daa66562fbe3c7a13eded022155c74b22ad30deee48d7
MD5 9da9c4829b34d065a1c1f975d588cb84
BLAKE2b-256 866af6b335491229d4dac10268f0edc2e3cc8af32288160bb897d88738bedca6

See more details on using hashes here.

Provenance

File details

Details for the file buffer_matcher-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for buffer_matcher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3881552c29c9653e21a76b8488a346cfc7280dddcd51b2a3a846c4bb63f75340
MD5 c59ee2b8116ef4739ca6fcc318af289b
BLAKE2b-256 7c79f97b1d1ee60433e28290b8140798574b6b6bed242875680d897c39641130

See more details on using hashes here.

Provenance

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