{"id":9737,"library":"fastnanoid","title":"Fast Nano ID","description":"Fastnanoid is a tiny, secure, URL-friendly, and highly performant unique string ID generator for Python, leveraging a Rust implementation via PyO3. It provides a drop-in replacement for other Nano ID implementations with a focus on speed. The current version is 0.4.3, with a release cadence that has seen several minor updates and performance improvements over the past year.","status":"active","version":"0.4.3","language":"en","source_language":"en","source_url":"https://github.com/oliverlambson/fastnanoid","tags":["id generation","unique id","nanoid","rust","performance"],"install":[{"cmd":"pip install fastnanoid","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary function is named 'nanoid' and is directly importable from the top-level package.","wrong":"import nanoid","symbol":"nanoid","correct":"from fastnanoid import nanoid"}],"quickstart":{"code":"from fastnanoid import nanoid\n\n# Generate a default Nano ID\nid_default = nanoid()\nprint(f\"Default ID: {id_default}\")\n\n# Generate a Nano ID with a specific length\nid_short = nanoid(size=10)\nprint(f\"Short ID:   {id_short}\")\n\n# Generate a Nano ID with a custom alphabet and length\nid_numeric = nanoid(alphabet=\"0123456789\", size=8)\nprint(f\"Numeric ID: {id_numeric}\")","lang":"python","description":"This quickstart demonstrates how to import the `nanoid` function and generate IDs with default settings, a specified length, or a custom alphabet."},"warnings":[{"fix":"Ensure Rust is installed and configured correctly (e.g., `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`) or check if an appropriate wheel is available for your environment.","message":"When installing on certain platforms (e.g., specific Linux distributions, ARM architectures, or very new Python versions) for which pre-compiled wheels are not available, pip may attempt to compile `fastnanoid` from source. This requires the Rust toolchain (rustup, cargo) to be installed on the system.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `nanoid(size=10)` and `nanoid(alphabet='abc')` instead of `nanoid(10)` or `nanoid('abc')`.","message":"The `nanoid` function expects `size` and `alphabet` as keyword arguments. Passing them positionally or using incorrect keyword names will result in a `TypeError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install fastnanoid` to install the package.","cause":"The `fastnanoid` package is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'fastnanoid'"},{"fix":"Use keyword arguments: `nanoid(size=10)` instead of `nanoid(10)`, and `nanoid(alphabet=\"abc\")` instead of `nanoid(\"abc\")`.","cause":"You are attempting to pass the size or alphabet as a positional argument to the `nanoid` function.","error":"TypeError: nanoid() takes 0 positional arguments but 1 was given"},{"fix":"Install the Rust toolchain using `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` and ensure it's available in your PATH. If issues persist, consult the `maturin` (Rust-Python binding tool) documentation.","cause":"This error, or similar 'failed to run custom build command' messages, indicates that the Rust compilation process failed during installation, likely due to missing Rust toolchain components or incompatible environment settings.","error":"error: can't find crate `fastnanoid_py`"}]}