Skip to main content

Provides functions for generating ordering strings

Project description

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.

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'

Other Languages

This is a Python port of the original JavaScript implementation by @rocicorp. That means that this implementation is byte-for-byte compatible with:

Language Repo
JavaScript https://github.com/rocicorp/fractional-indexing
Go https://github.com/rocicorp/fracdex

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fractional-indexing-0.1.2.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.11.4

File hashes

Hashes for fractional-indexing-0.1.2.tar.gz
Algorithm Hash digest
SHA256 29440eaa0205df6fc1d8b7557c7095a814ff977ff5d37ed3995f579d43d2f42a
MD5 0e5d39d1bc8b4d4c40b275d776120c53
BLAKE2b-256 002bd743e662b9bf0353b0597f3cbbed14db9d46306bd4a6dbf1e1c2e4fa77ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fractional_indexing-0.1.2-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.11.4

File hashes

Hashes for fractional_indexing-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50768e7586123907294e9182b7042d5a1a82748ec0e69b3428161ba2cbe5f008
MD5 a8bfd573cd75cad12204638fa715f685
BLAKE2b-256 8f0a1db2b37feeab9e8631bb6dd90ccbb9b85a19e0953593e0f1740d00529721

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