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
Built Distribution
Close
Hashes for fractional-indexing-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a168ac1af4f422b828d95a8d9f5c1d8ef00df988efa2acfa66f649f3250ef229 |
|
MD5 | 37ac7c75623f5321ba8236584786725a |
|
BLAKE2b-256 | e14bed5da499d530417919d3862b7673307574664f37e7e69927212f079d033c |
Close
Hashes for fractional_indexing-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88289af9efaeb484677f288b4b9a263216923ffe4b9ed7c44564203c4d610e8 |
|
MD5 | 2d020ecd4cdf1dcbb2c41014de9b67d1 |
|
BLAKE2b-256 | 517adc94332716a74cc23117414837934cd7aea90f73f75e6e6ed8fc5a81df8a |