Skip to main content

Provides functions for generating ordering strings

Project description

Fractional Indexing

This is a Python port of the original JavaScript implementation by @rocicorp: https://github.com/rocicorp/fractional-indexing


This is based on Implementing Fractional Indexing by David Greenspan .

Fractional indexing is a technique to create an ordering that can be used for Realtime Editing of Ordered Sequences.

This implementation includes variable-length integers, and the prepend/append optimization described in David's article.

This should be byte-for-byte compatible with rocicorp/fractional-indexing (JavaScript) and rocicorp/fracdex (Go).

Installation

$ pip install fractional-indexing

Usage

from fractional_indexing import generate_key_between


first = generate_key_between(None, None)
assert first == 'a0'

# Insert after 1st
second = generate_key_between(first, None)
assert second == 'a1'

# Insert after 2nd
third = generate_key_between(second, None)
assert third == 'a2'

# Insert before 1st
zeroth = generate_key_between(None, first)
assert zeroth == 'Zz'

# Insert in between 2nd and 3rd. Midpoint
second_and_half = generate_key_between(second, third)
assert second_and_half == 'a1V'

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

fractional-indexing-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

fractional_indexing-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file fractional-indexing-0.1.1.tar.gz.

File metadata

  • Download URL: fractional-indexing-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for fractional-indexing-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e3e1a73b8008facad095fc0a612b5d7ce8eae8a2c06019f5fe5fbd430f0d355a
MD5 f87fbadf5a25b273399dfe148d993ea8
BLAKE2b-256 320a4ca7d07fe808377ecd3a6be8e155409cad44bd27a77ff6862f74fbc0df9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fractional_indexing-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for fractional_indexing-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6011ffe89856b36735f90d311e0a814c526ae4f7b96f6b0618d91f1669e83965
MD5 4b4c9d38d84a083fdb7c8fe5f6195627
BLAKE2b-256 4d1c2acbddd2d71355ba722151076cfd499904503f089591cc588cc8b883086d

See more details on using hashes here.

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