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

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.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

fractional_indexing-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fractional-indexing-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 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.0.tar.gz
Algorithm Hash digest
SHA256 a168ac1af4f422b828d95a8d9f5c1d8ef00df988efa2acfa66f649f3250ef229
MD5 37ac7c75623f5321ba8236584786725a
BLAKE2b-256 e14bed5da499d530417919d3862b7673307574664f37e7e69927212f079d033c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fractional_indexing-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c88289af9efaeb484677f288b4b9a263216923ffe4b9ed7c44564203c4d610e8
MD5 2d020ecd4cdf1dcbb2c41014de9b67d1
BLAKE2b-256 517adc94332716a74cc23117414837934cd7aea90f73f75e6e6ed8fc5a81df8a

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