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
Built Distribution
Close
Hashes for fractional-indexing-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3e1a73b8008facad095fc0a612b5d7ce8eae8a2c06019f5fe5fbd430f0d355a |
|
MD5 | f87fbadf5a25b273399dfe148d993ea8 |
|
BLAKE2b-256 | 320a4ca7d07fe808377ecd3a6be8e155409cad44bd27a77ff6862f74fbc0df9d |
Close
Hashes for fractional_indexing-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6011ffe89856b36735f90d311e0a814c526ae4f7b96f6b0618d91f1669e83965 |
|
MD5 | 4b4c9d38d84a083fdb7c8fe5f6195627 |
|
BLAKE2b-256 | 4d1c2acbddd2d71355ba722151076cfd499904503f089591cc588cc8b883086d |