{"id":21358,"library":"fractional-indexing","title":"fractional-indexing","description":"A Python implementation of fractional indexing for generating ordering strings (keys) between others, commonly used for sortable IDs in collaborative applications. Current version 0.1.3, stable maintenance mode.","status":"active","version":"0.1.3","language":"python","source_language":"en","source_url":"https://github.com/httpie/fractional-indexing-python","tags":["fractional-indexing","ordering","keys","sortable-ids"],"install":[{"cmd":"pip install fractional-indexing","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Main function to generate a key between two others.","symbol":"generate_key","correct":"from fractional_indexing import generate_key"},{"note":"Alternative name for the same function (alias).","symbol":"generate_key_between","correct":"from fractional_indexing import generate_key_between"},{"note":"Base62 digit set used internally.","symbol":"BASE_62_DIGITS","correct":"from fractional_indexing import BASE_62_DIGITS"}],"quickstart":{"code":"from fractional_indexing import generate_key\n\n# Generate first key\nkey1 = generate_key()\nprint(key1)  # e.g., 'a0'\n\n# Generate key after key1\nkey2 = generate_key(after=key1)\nprint(key2)  # e.g., 'a1'\n\n# Generate key between key1 and key2\nkey_between = generate_key(between=key1, after=key2)\nprint(key_between)  # e.g., 'a0V'","lang":"python","description":"Basic usage of generate_key to create ordering strings."},"warnings":[{"fix":"Ensure single-threaded or use a locking mechanism if generating keys in a multithreaded context.","message":"The library is not widely tested for concurrent generation; concurrent calls may produce duplicate keys if shared state is not managed.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not reuse keys across different datasets without proper context separation; generate a fresh initial key for each independent ordering.","message":"Keys are not guaranteed to be unique across multiple independent generators with the same initial state. Always start with no arguments to get a unique initial key per session.","severity":"gotcha","affected_versions":"all"},{"fix":"If you need custom encoding, consider forking the library or using another approach.","message":"The library does not support specifiying a custom base-digit set. It uses a fixed 62-digit set internally.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from fractional_indexing import generate_key' (and call it with between= and after= parameters).","cause":"The function was renamed in older versions. In 0.1.2+, it's available as 'generate_key'.","error":"ImportError: cannot import name 'generate_key_between' from 'fractional_indexing'"},{"fix":"Use keyword arguments: generate_key(between='a0', after='a2') or generate_key() for the first key.","cause":"Using an incorrect function signature; the function expects keyword arguments, not positional.","error":"TypeError: generate_key() missing 3 required positional arguments: 'start', 'end', and 'before_or_after'"},{"fix":"Ensure the 'after' argument is lexicographically larger than the 'between' argument.","cause":"The 'after' key must be lexicographically greater than the 'between' key (or the before/between key).","error":"ValueError: after must be greater than before"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}