Skip to main content

Encode tuples of primitive types into bytestrings preserving the lexicographic order

Project description


title: Lexicographic Encoding

Lexicographic Encoding

Easily encode tuples of primitive types to bytestrings preserving lexicographic encoding. This means that you can later order the resulting bytestring and you will maintain the order of tuples.

Use Cases

Typically key-value stores only allow to use bytestrings as keys, which are a little awkward to work with if one needs a bit of structure on them. For example LevelDB offers a custom comparator to deal with such a situation, but many other storages do not.

This package allows you to free from such constraint, using an encoding that maintains the inherent ordering.

Stability

The project is to be considered beta. The provided API won't change, but it has not been tested in real-world yet (it has a big automated test suite though).

Any feedback will be appreciated. For any question or bug report please open an issue.

Quick Example

from lexicographic_encoding import lexpackb, lexunpackb, is_prefix_of

# Then pack everything preserving lexicographic order
# The following are all True
lexpackb(-1) > lexpackb(-2)
lexpackb(102) > lexpackb(20)
lexpackb(("Tom", 109)) > lexpackb(("Tom", 18))

Documentation

Documentation of the project can be found here.

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

lexicographic-encoding-0.1.1.tar.gz (17.5 kB view details)

Uploaded Source

File details

Details for the file lexicographic-encoding-0.1.1.tar.gz.

File metadata

  • Download URL: lexicographic-encoding-0.1.1.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.11

File hashes

Hashes for lexicographic-encoding-0.1.1.tar.gz
Algorithm Hash digest
SHA256 875f2f35687847d89e3a0129ad273bbb053643b655d5948fee122a9c3b95af24
MD5 495de7b9fcaaf63be85a8152ee6292ce
BLAKE2b-256 7ab4343c588068917e5f1c54ec0448672c47bea2bcf3ac48fd6f6d46f1d2e397

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page