skillfed

fractional-indexing

Provides functions for generating ordering strings

fractional-indexing v0.1.3 217.5K downloads/30d#9,356 on PyPI38
Permissive license CC0 1.0 Universal Active released

What it is and what it does

Fractional indexing is a technique for generating sortable string keys that represent positions in an ordered sequence. Instead of storing explicit numeric indices that require recalculation when items are inserted, you generate a key that sorts between any two existing keys—or at the beginning or end if no neighbors exist. This is particularly useful in collaborative editing systems where multiple clients insert items concurrently without coordinating a central sequence number.

The package provides three main functions: `generate_key_between()` to create a single key between two positions, `generate_n_keys_between()` to generate multiple keys at once, and `validate_order_key()` to check if a key is valid. By default it uses Base62 encoding, but you can supply custom digit sets. The implementation includes variable-length integers and prepend/append optimizations from the original design.

Use it for:

  • Collaborative document editors where multiple users insert paragraphs/sections concurrently without a central server assigning indices
  • Todo list applications storing item order as string keys in a database, allowing insertions between items without updating all subsequent records
  • Real-time multiplayer games maintaining player action order or entity positions in a way that merges concurrent updates
  • CMS systems storing content hierarchy where new pages can be inserted between existing ones without reordering the entire tree
  • Distributed databases or event logs where you need a total ordering that can be computed locally without coordination

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Generates sortable string keys for inserting items into ordered sequences without requiring full re-indexing, using fractional indexing to compute positions between existing keys.

Yes, if you need to maintain ordered sequences in a collaborative or distributed context. The package is lightweight, permissively licensed, and solves a specific problem well. The main caveat is that the last release was over a year ago despite active repository commits—verify it works with your target Python version before relying on it in production.

Install

fractional-indexing on PyPI

pip

pip install fractional-indexing

uv

uv add fractional-indexing

poetry

poetry add fractional-indexing

Installing fractional-indexing

Before you install

Low friction: pure Python wheel with only setuptools as a runtime dependency. Repository is active with a recent commit (2026-08-06), though the last release was over a year ago (2023-08-13).

License in practice

CC0 1.0 Universal (public domain equivalent) means no restrictions on use, modification, or distribution—you can use this freely in any project without attribution requirements.

Quickstart

from fractional_indexing import generate_key_between

# Insert at the beginning
first = generate_key_between(None, None)
# Returns 'a0'

# Insert after first
second = generate_key_between(first, None)
# Returns 'a1'

Verify before relying

  • Whether the package works with modern Python versions (requires_python is empty in metadata)

Package facts

License CC0 1.0 Universal (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — setuptools
Maintenance actively maintained — 1,097 days since the last release
Last repo commit
First released
Downloads 217,545/month — #9,356 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fractional_indexing-0.1.3-py3-none-any.whl

Tags

fractional indexing keysordered sequence insertionrealtime collaborative editinggenerate sort keys between valuesordering without reindexingposition keys for lists
collaborative-editingordering-algorithmdistributed-systems

More Software Development packages