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
Built Distribution
Close
Hashes for fractional-indexing-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29440eaa0205df6fc1d8b7557c7095a814ff977ff5d37ed3995f579d43d2f42a |
|
MD5 | 0e5d39d1bc8b4d4c40b275d776120c53 |
|
BLAKE2b-256 | 002bd743e662b9bf0353b0597f3cbbed14db9d46306bd4a6dbf1e1c2e4fa77ea |
Close
Hashes for fractional_indexing-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50768e7586123907294e9182b7042d5a1a82748ec0e69b3428161ba2cbe5f008 |
|
MD5 | a8bfd573cd75cad12204638fa715f685 |
|
BLAKE2b-256 | 8f0a1db2b37feeab9e8631bb6dd90ccbb9b85a19e0953593e0f1740d00529721 |