Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

I Built a Search Engine With Zero Dependencies — Just Python 3.14's Standard Library

Описание и применение

SwiftSearch показывает, что полнотекстовый поиск можно реализовать без сторонних библиотек, используя только стандартную библиотеку Python 3.14.

Задача

Modern web apps often add heavy search stacks (Elasticsearch, Whoosh, FastAPI, etc.) that inflate dependencies, runtime, and complexity for simple local search needs.

Результат

SwiftSearch demonstrates that a lightweight, dependency‑free search engine can be built with only Python’s standard library, achieving sub‑millisecond query times and eliminating external services.

Рабочий процесс

  • 1. Build an inverted index in memory with collections.defaultdict and dataclasses to store postings and document frequencies.
  • 2. Tokenize text using unicodedata.normalize('NFC') and a simple alphanumeric split.
  • 3. Serve HTTP requests with http.server, handling dual routing (API and static assets) by inspecting self.path and setting headers manually.
  • 4. Return JSON search results and render a demo page for the command‑palette UI.
  • 5. Verify zero external imports with a grep check across the codebase.
  • 6. Run the server with python -m swiftsearch serve and perform queries like /search?q=python.

Доказательства

SwiftSearch runs with a single command (python -m swiftsearch serve), using only stdlib modules: collections.defaultdict for inverted indexing, unicodedata for tokenization, http.server for the API, and a simple linear scoring formula.

Источник

Every import resolved to a Python 3.14 built‑in: argparse, collections, dataclasses, html, http.server, json, pathlib, time, unicodedata, urllib.parse.

Источник

  • Дата записи: 2026-09-11T04:01:14.660Z