Skip to main content

fast-code-embed (Python)

Pythonic interface to the fast-code-embed C library: algorithmic code embeddings using TF-IDF + pretrained nomic-embed-code token vectors (with optional Reflective Random Indexing).

  • No GPU, no API keys, no model download — the 30 MB vector table is compiled into the wheel.
  • Sub-millisecond scoring — lookup-based, no transformer inference.

Status: sketch / not yet published. This package mirrors the Java binding's surface. The wheel links the prebuilt C static library, so make lib must run before building (cibuildwheel handles this in CI).

Install (once published)

pip install fast-code-embed

Usage

import fast_code_embed as fce

# Global config (maps to the C library's process-state toggles; set once).
fce.set_dim(768)              # 256 or 768
fce.set_idf_weighting(True)
fce.set_abbrev_expansion(False)

with fce.Corpus() as corpus:
    corpus.add_doc("parse_config", "def parse_config(path): ...")
    corpus.add_doc("retry_request", "def retry_request(url, attempts): ...")
    # or: corpus.add_files(["a.py", "b.py"])  # chunk + tokenize in C
    corpus.finalize()

    for hit in corpus.search("load configuration from disk", k=10):
        print(f"{hit.score:.3f}  {hit.label}")

    # Persist while the corpus is still open (same-build cache, not portable
    # across dim / byte-order).
    corpus.save("index.fce")

# Reload later into a fresh corpus.
with fce.Corpus.load("index.fce") as reloaded:
    hits = reloaded.search("retry with backoff", k=5)

Search modes

from fast_code_embed import Mode
corpus.search("retry with backoff", k=5, mode=Mode.BRUTEFORCE)  # exhaustive
corpus.search("retry with backoff", k=5, mode=Mode.FAST)        # inverted index
corpus.search("retry with backoff", k=5, mode=Mode.TFIDF)       # tf-idf + rerank
# Mode.DEFAULT == AUTO (fast path, brute fallback)

Mode.FAST/TFIDF/AUTO only retrieve documents sharing a literal token with the query; use Mode.BRUTEFORCE when exhaustive recall matters.

Building locally

cd ..             # repo root
make lib          # produces build/libfast_code_embed.a (with embedded blob)
cd python
pip install -e .  # compiles the cffi extension against the archive

Building wheels

pip install cibuildwheel
cibuildwheel --output-dir wheelhouse python

Metadata

Release files for fast-code-embed 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fast-code-embed 0.1.2
File
fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl CPython 3.9 abi3 Linux glibc 2.34+ x86-64 Details
fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl CPython 3.9 abi3 Linux glibc 2.34+ ARM64 Details
fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl CPython 3.9 abi3 macOS 11.0+ x86-64 Details
fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 77.7 MB

Release files / fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl

Download URL fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl
Size 19.5 MB
Tags CPython 3.9 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
f6c22b8b0264a89c3d1b3533565a3dc056b045cca16b008512cc4a33b0faa623
BLAKE2b-256 checksum
How to use checksums
adf7d06e0ed50cc140fae6a664b6da9e8b56151f428472bf8297512a2a6cd05b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.

Transparency log

Release files / fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl

Download URL fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl
Size 19.4 MB
Tags CPython 3.9 Linux glibc 2.34+ ARM64 abi3
SHA-256 checksum
How to use checksums
4d9ee3d386d4ae5c53fded75735e689b5b5f356c0dfe75ef73f28a47d5505f9f
BLAKE2b-256 checksum
How to use checksums
f9466312f3e0810506d5bbab70b10769060d29c1477131264c3c9b02dae838bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.

Transparency log

Release files / fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl

Download URL fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl
Size 19.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
f69cc578dc1904269a0e0a77c50083c83b1331d536aa3794dd72c2af27e78149
BLAKE2b-256 checksum
How to use checksums
b3cda17ad685c836ca387fc3724d3a61c6dc807e462bceb05558390dc6c7da3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.

Transparency log

Release files / fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl

Download URL fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl
Size 19.5 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b719b516a994f265f2a4eb0ffb07ece7660a57a0d962f6925f024001be3e6be4
BLAKE2b-256 checksum
How to use checksums
3ba9fe868130e20cdfdec1363831fd86ea72bce4b4d47f637154bce934025ec0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page