thehardwarestore.ai

where AI agents shop for the right tools

── 98840 repos indexed ── | filtered by tag: #python-library
scikit-learn/scikit-learn ★ 67456 27471 APPLICATION

scikit-learn is a production-grade machine learning library implemented in Python with Cython extensions for performance. It provides a unified API for classification, regression, clustering, dimensionality reduction, model selection, preprocessing, and feature extraction, all built on top of NumPy, SciPy, and joblib. The library follows a consistent estimator pattern (fit/predict/transform) with base classes and mixins that enforce parameter validation, metadata routing, and tag-based introspection. The architecture is modular, with each algorithm group (e.g., linear models, trees, SVMs, ensembles) living in its own subpackage, and shared utilities in `sklearn.utils`. External dependencies are minimized by vendoring array API compatibility layers and small specialized libraries. The repository is a prime example of a well-engineered open-source project with extensive unit tests (covering edge cases, sparse/dense variants, and GPU via array API), continuous integration across platforms, and a community-driven contribution model. In production, scikit-learn is used as a library that users import and call programmatically—not as a service. Its key entry points are the estimator classes (`LogisticRegression`, `RandomForestClassifier`, `PCA`, etc.) and utility functions (`train_test_split`, `cross_val_score`, `GridSearchCV`). Data flows from user-provided numpy arrays or pandas DataFrames through `fit` methods, which validate input, transform data through steps, and fit internal parameters. The library also includes a robust callback system for monitoring training progress, a flexible pipeline composition framework, and multiple scoring/metrics for evaluation. While primarily CPU-based, recent work on Array API support enables GPU acceleration through PyTorch or CuPy backends. The codebase exhibits exceptional craftsmanship: self-documenting test fixtures, parametrized test suites that cover all estimator combinations, a changelog fragment system (towncrier), and a formal deprecation policy with clear FutureWarnings. Components like the `SelectorMixin` pattern, the link function hierarchy for GLMs, and the callback infrastructure can be extracted and reused in other machine learning projects with minimal changes. The vendored array API compatibility layer is a standout example of supporting multiple array backends without external dependency bloat. The repository sets the benchmark for Python ML library design.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 4 reusable components found
Textualize/rich ★ 57441 2371 APPLICATION

Rich is a Python library for rendering rich text, beautiful formatting, and advanced content to the terminal. It provides a Console class as its central abstraction, which manages terminal capabilities (color systems, width, encoding) and renders a composable hierarchy of 'renderables' — objects implementing the __rich_console__ protocol that yield Segment tuples (text, style, control codes). The architecture is a monolithic library with clean internal modularity: the Console orchestrates rendering, Segment is the low-level output primitive, and higher-level renderables (Table, Tree, Markdown, Syntax, Progress, Layout, Live) compose into each other via the protocol. Key entry points are the module-level print/inspect/print_json functions (backed by a global Console singleton), the Console class for explicit control, and CLI modules (python -m rich.syntax, python -m rich.markdown, etc.). The library handles cross-platform terminal differences including Windows legacy console API calls via ctypes, Jupyter notebook HTML rendering, and Unicode width calculations across 21 Unicode versions. External dependencies are minimal: pygments for syntax highlighting and markdown-it-py for Markdown parsing. The codebase demonstrates exceptional craftsmanship in its terminal rendering pipeline, careful handling of edge cases (CJK width, emoji variants, control codes, broken file-like objects), and a well-designed protocol system that enables arbitrary composition of renderables. The Segment-based rendering architecture is both performant and elegant, allowing style application, line splitting, and cell-width calculations to be composed as transformations over segment sequences.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 5 reusable components found
pydantic/pydantic ★ 28971 3026 APPLICATION

Pydantic is a high-performance Python library for data validation and serialization, driven by Python type hints. Its architecture is a hybrid Python/Rust system: the Python layer provides the user-facing API (BaseModel, TypeAdapter, validate_call, dataclass decorator, field validators/serializers) and schema generation logic, while the Rust core (pydantic-core) implements the actual validation and serialization engines for maximum speed. The library supports a wide range of types including primitives, collections, unions, generics, dataclasses, TypedDicts, and custom types, with strict/lax modes, alias handling, and JSON schema generation. Key entry points are BaseModel for model definitions, TypeAdapter for standalone type validation, and the validate_call decorator for function argument validation. External dependencies are minimal: pydantic-core (Rust binary) is required, and optional integrations include email-validator, python-dotenv, and hypothesis. The codebase is exceptionally well-engineered, with extensive test coverage, performance benchmarks, mypy/pyright plugin support, and a plugin system for lifecycle hooks. It maintains backward compatibility with Pydantic V1 through a vendored v1 package and deprecation shims.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 5 reusable components found
tobymao/sqlglot ★ 9682 1334 APPLICATION

SQLGlot is a pure-Python SQL parser, transpiler, optimizer, lineage analyzer, diff engine, and in-process executor with support for 30+ SQL dialects including Snowflake, BigQuery, DuckDB, Spark, Trino, Postgres, and MySQL. The core pipeline tokenizes SQL source, parses it into a rich expression AST, applies optimizer passes such as column qualification, predicate pushdown, subquery decorrelation, type annotation, and simplification, then generates dialect-specific SQL. It also includes a planner/executor for running queries against Python data structures and a CLI for transpilation and tokenization. Despite the breadth of dialect coverage, the architecture centralizes shared language machinery in base tokenizer/parser/generator classes, with dialects as declarative overrides, and the library has zero required runtime dependencies.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 6 reusable components found
HypothesisWorks/hypothesis ★ 9084 688 APPLICATION

Hypothesis is a mature property-based testing library for Python. The core runtime, exposed via @given in hypothesis/src/hypothesis/__init__.py, executes each decorated test many times with inputs drawn from composable SearchStrategy objects (integers, floats, text, regex, collections, datetimes, plus extras generating numpy arrays, pandas DataFrame/Series, Django models/forms, lark grammars, and more). All randomness flows through a formal choice IR (hypothesis/internal/conjecture/choice.py) into a pluggable PrimitiveProvider; the default conjecture engine (engine.py) maintains a DataTree of previously seen choice prefixes to avoid redundant exploration and detect flaky tests, and when a failure is found a cascade of shrinking passes (shrinker.py plus the shrinking/ package) reduces it to a minimal counterexample. An example database layer (in-memory, directory-based, and GitHub-artifact backends) persists and replays failures across runs, and an observability subsystem emits structured JSONL metadata per test case. The package also ships application surfaces beyond the library API: a pytest plugin (statistics, health checks, capture, deadline reporting), a CLI (a ghostwriter that auto-generates property tests from signatures/docstrings, plus codemods and failure-patching commands), and a stateful-testing framework (RuleBasedStateMachine, Bundle, @rule/@invariant). A PyO3 Rust extension (hypothesis/rust) accelerates float encoding, and the provider abstraction is validated by an embedded conformance test suite so third-party backends (e.g., CrossHair symbolic execution) can drive generation. Internal subsystems are unusually well-factored — filter predicates are rewritten into tighter strategy constraints via AST analysis, lambda sources are recovered from bytecode, and Unicode character ranges are modelled as interval sets — making several modules reusable outside the project. This is a developer-tool library with CLI and pytest entry points, not a runtime service; the repo also includes its own build/release tooling, a Pelican website, docs, and a very large self-testing suite with enforced 100% branch coverage.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 5 reusable components found
hynek/structlog ★ 4939 294 APPLICATION

structlog is a production-ready structured logging library for Python. It provides a composable processor pipeline that transforms event dictionaries (key-value pairs) through filtering, enrichment, and rendering stages, ultimately producing outputs like JSON, console color, logfmt, or key-value format. The library integrates deeply with Python's standard logging module, Twisted, and asyncio, offering context management via contextvars, thread-local storage (deprecated), and a rich set of processors for timestamps, call-site parameters, exception formatting, and traceback extraction. Its architecture centers on immutability, pure functions, and lazy proxy caching, making it both flexible and performant. The codebase exhibits exceptional craftsmanship: extensive type annotations, 100% test coverage, clear documentation, and a well-defined backward-compatibility policy. It is not a data science or research project; it is a software library for application instrumentation.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 1 reusable components found
tox-dev/filelock ★ 973 144 APPLICATION

This repository is the `filelock` library, a cross-platform file locking solution for Python. It provides multiple synchronization backends: native OS locks (using `fcntl.flock` on Unix and `LockFileEx` on Windows), cooperative soft locks based on marker files with stale detection, strict hard-link-based locks for fail-closed semantics, SQLite-backed read/write locks, and lease-based locks with heartbeat and compromise detection. All backends are available as synchronous context managers and async wrappers. The library handles edge cases like fork safety, cancellation, timeout, reentrancy, and error aggregation through policies. It is production-grade, used by projects such as tox, pip, virtualenv, and Hugging Face Hub, and is extensively tested across Linux, Windows, macOS, and Android/Termux in CI.

RATING: 9.9/10 MAINT: active DRIFT: low
▸ 6 reusable components found
librosa/librosa ★ 8683 1087 APPLICATION

librosa is a Python library for audio and music signal processing, providing a comprehensive set of algorithms for music information retrieval (MIR). It includes functions for loading audio in various formats, computing time-frequency representations (STFT, CQT, VQT, mel spectrogram), extracting features (chroma, MFCC, spectral descriptors, tempogram, rhythm features), pitch tracking (YIN, pYIN), beat and onset detection, source separation (HPSS, NMF), sequence alignment (DTW, Viterbi), and audio effects (time stretch, pitch shift, pre-emphasis). The library also offers a rich visualization module for plotting waveforms, spectrograms, and other audio representations. The architecture is modular, organized into subpackages: `librosa.core` for core DSP and I/O, `librosa.feature` for feature extraction, `librosa.util` for utility functions (array manipulation, matching, caching), `librosa.filters` for filter bank construction, `librosa.display` for visualization, and domain-specific modules like `librosa.beat`, `librosa.onset`, `librosa.decompose`, `librosa.effects`, `librosa.segment`, and `librosa.sequence`. Submodules are lazily loaded to reduce import time. The library is designed for both interactive use (notebooks) and integration into larger applications. Key entry points include `librosa.load` for audio I/O, `librosa.stft`/`librosa.cqt` for time-frequency transforms, `librosa.feature.*` for feature extraction, `librosa.beat.beat_track` for beat tracking, `librosa.onset.onset_detect` for onset detection, `librosa.display.specshow`/`librosa.display.waveshow` for visualization, and `librosa.effects.*` for audio effects. Data flows typically involve loading audio, optionally resampling, computing a spectrogram, extracting features, and then analyzing or visualizing the results. External dependencies include numpy, scipy, numba (for JIT acceleration), matplotlib (for display), soundfile/soxr/resampy (for audio I/O and resampling), pooch (for example data management), and scikit-learn (for NMF decomposition). The library is well-tested with a comprehensive test suite and continuous integration across multiple Python versions and operating systems. While primarily a software library, it includes research-oriented features such as non-Western music theory support, just intonation, and implementations of algorithms from academic publications, giving it a hybrid character.

RATING: 9.8/10 MAINT: active DRIFT: low
▸ 5 reusable components found
psf/requests ★ 54347 11117 APPLICATION

Requests is a widely-used Python HTTP library that provides a simple, elegant API for making HTTP/1.1 requests. It abstracts away the complexities of urllib3, offering features like session persistence, cookie handling, automatic content decoding, SSL/TLS verification, and various authentication mechanisms (Basic, Digest, OAuth via extensions). The library is designed as a set of loosely coupled modules: the public API (api.py) delegates to a Session object (sessions.py) which manages connection pooling and request defaults; the HTTPAdapter (adapters.py) bridges to urllib3; and models.py defines Request, PreparedRequest, and Response objects. The codebase is well-structured, extensively tested, and follows a feature-freeze policy, focusing on stability and compatibility rather than new features. It is not an application or data research project; it is a pure library distributed via PyPI.

RATING: 9.6/10 MAINT: active DRIFT: low
▸ 4 reusable components found
roboflow/supervision ★ 51054 4861 APPLICATION

Supervision is a model-agnostic computer vision utility library developed by Roboflow. It provides a comprehensive set of tools for post-processing detection, segmentation, and keypoint outputs from popular models (YOLO, Ultralytics, DETR, SAM, VLMs like Gemini and PaliGemma). It standardizes model outputs into `Detections` and `KeyPoints` objects, then offers annotators for visualization, tools for zone counting, tracking, line crossing, and tiled inference for large images. It also includes dataset conversion (COCO, YOLO, Pascal VOC, LabelMe, CreateML), object detection metrics (COCO mAP, F1, precision/recall), and video processing pipelines. The library is designed for production use with extensive testing, type hints, and an optional OpenCV fallback. While primarily an application library, it also contains research-oriented components such as VLM parsers and advanced mask representations (CompactMask). The codebase exhibits high craftsmanship with well-isolated components, thorough tests, and performance optimizations.

RATING: 9.6/10 MAINT: active DRIFT: low
▸ 4 reusable components found
encode/django-rest-framework ★ 30198 7094 APPLICATION

Django REST Framework (DRF) is a mature, production‑stable Python library for building RESTful Web APIs on top of Django. It provides a comprehensive set of reusable components including serializers, views, authentication backends, permission classes, throttling, filtering, pagination, versioning, and schema generation. The library is designed as a set of pluggable, configurable modules that integrate into Django projects via settings and URL configuration. Key entry points are the APIView base class, ViewSets, ModelViewSets, and Serializer/ModelSerializer classes. Data flows follow a standard Django request‑response cycle: an HTTP request is routed to a view, which uses serializers to validate and transform data, interacts with models or other data sources, and returns a Response object that is rendered by a configurable renderer. External dependencies include Django (5.2–6.1), and optional packages for markdown rendering, YAML output, OpenAPI schema generation, and more. The library is extensively tested with pytest and includes a browsable API interface, internationalization, and a formal deprecation policy.

RATING: 9.6/10 MAINT: active DRIFT: low
▸ 6 reusable components found
celery/celery ★ 28938 5209 APPLICATION

Celery is a distributed task queue system for executing asynchronous work across worker nodes. It provides a flexible architecture with pluggable brokers (RabbitMQ, Redis, etc.), result backends, and concurrency models (prefork, eventlet, gevent). The system enables producers to send tasks to a broker, workers to execute tasks and store results, and clients to retrieve results. Key features include periodic task scheduling (beat), workflow primitives (canvas), remote control, and monitoring. The codebase exhibits strong modularity through extension points like signals, bootsteps, and pluggable backends.

RATING: 9.6/10 MAINT: active DRIFT: low
▸ 5 reusable components found
pandas-dev/pandas ★ 49915 20462 APPLICATION

pandas is a high-performance Python library for data manipulation and analysis, providing the DataFrame and Series data structures as its core abstractions. The codebase is a hybrid of Python and Cython/C++ (via Cython and C extensions) with performance-critical operations in low-level modules under `pandas/_libs` (e.g., tslibs for time series, parsers for CSV, and window aggregations). The architecture is modular: core data structures (`pandas/core/`), I/O readers/writers (`pandas/io/`), plotting backends (`pandas/plotting/`), and an extensible extension array interface (`pandas/core/arrays/`) that allows third-party types to integrate seamlessly. Key entry points are `pandas/__init__.py` (public API), `pandas/io/api.py` (I/O functions), and `pandas/core/api.py` (internal API). The library is heavily tested with over 2000 test files, and its CI/CD pipeline covers multiple platforms and Python versions.

RATING: 9.5/10 MAINT: active DRIFT: low
▸ 3 reusable components found
python-telegram-bot/python-telegram-bot ★ 29515 6159 APPLICATION

python-telegram-bot is a pure Python, asynchronous library that provides both low-level bindings to the Telegram Bot API and a high-level application framework for building Telegram bots. In production, it handles authentication, message sending/receiving, update processing, and bot lifecycle management. The library is used by developers to create bots that can respond to commands, messages, inline queries, callback queries, and other Telegram events, with support for payments, passports, polls, and more. The architecture is organized into three layers: the core `telegram` package containing data models for all Telegram API types (Chat, User, Message, etc.) with consistent serialization and equality semantics; the `telegram.ext` extension framework providing handlers (CommandHandler, MessageHandler, ConversationHandler), an Application class for orchestrating update processing, job queues, persistence, and rate limiting; and the `telegram.request` layer using httpx for async HTTP communication. The library uses async/await throughout and follows a handler-based event-driven pattern. Key entry points include `telegram.ext.Application` (built via `ApplicationBuilder`), `telegram.Bot` for direct API calls, and various handler classes. The primary data flow involves receiving updates from Telegram via polling or webhook, parsing them into `Update` objects, dispatching to registered handlers based on filters, and executing callback functions that can call Bot methods to respond. The library supports custom context types, persistent storage of bot/user/chat data, and scheduled jobs. External dependencies are minimal: `httpx` is the only required runtime dependency. Optional features require additional packages: `cryptography` for Telegram Passport, `APScheduler` for job queues, `cachetools` for callback data caching, `tornado` for webhook server, `aiolimiter` for rate limiting, and `pytz`/`zoneinfo` for timezone support. The library is extensively tested with both offline unit tests and online integration tests against the live Telegram API.

RATING: 9.5/10 MAINT: active DRIFT: low
▸ 4 reusable components found
sktime/sktime ★ 10063 2434 APPLICATION

sktime is a large, actively developed Python library that provides a unified scikit-learn-style estimator interface for time series machine learning. It is not a single-purpose application or service; it is a framework with a central registry, a datatype/mtype conversion system, tag-based estimator metadata, and a sophisticated automated test suite that generates per-estimator tests from scenarios. The dominant character is application/library, though it has strong research-data aspects: bundled datasets, benchmark suites, and algorithm implementations drawn from the time-series literature (forecasting, classification, clustering, change-point detection, transformations, alignment, distances/kernels, and parameter estimation).

RATING: 9.5/10 MAINT: active DRIFT: low
▸ 4 reusable components found
Kozea/WeasyPrint ★ 9680 894 APPLICATION

WeasyPrint is a production-grade Python library and CLI that renders HTML/CSS documents to PDF with high fidelity to print-focused web standards. In production it parses HTML via tinyhtml5, parses and validates CSS via tinycss2/cssselect2, builds a CSS box tree, runs full CSS layout algorithms for block, inline, table, flex, grid, multicolumn, floats, and paged media, then paints the result into a PDF via pydyf. It also renders embedded and standalone SVG, embeds and subsets fonts through Pango, HarfBuzz, Fontconfig, and fontTools, and supports PDF/A, PDF/UA, PDF/X, PDF forms, attachments, bookmarks, metadata, and e-invoice flavors such as Factur-X/ZUGFeRD. The main entry points are the `weasyprint` command-line tool (`weasyprint/__main__.py`) and the public Python API exposing `HTML`, `CSS`, `Document`, and `Page` (notably `HTML(...).write_pdf(...)`). Architecturally the repository is a layered pipeline rather than a monolith or microservice: CSS property validation and computed-value resolution feed a formatting-structure builder, which produces boxes; those boxes go through layout modules that handle pagination and page-breaking; a drawing layer converts the laid-out box tree into PDF stream operations; and the PDF package assembles final file objects, metadata, and conformance variants. The code is heavily specification-driven, with many docstring references to CSS 2.1, CSS Paged Media, CSS Flexbox/Grid, SVG, and PDF standards. Extensive pixel-comparison tests, regression tests tied to GitHub issues, and CI workflows for PDF/A and PDF/UA validation back the implementation. External runtime dependencies include pydyf, tinyhtml5, tinycss2, cssselect2, Pyphen, Pillow, fontTools, and native Pango/HarfBuzz/Fontconfig libraries; Ghostscript is used only by the test suite for rendering comparisons. The codebase is mature and generally well-structured, with clean separation between CSS processing, layout, drawing, and PDF output. It contains some inevitable complexity around pagination, table layout, and font handling, plus a set of `xfail` tests and TODO comments marking known spec coverage gaps, but overall it is one of the strongest open-source HTML-to-PDF engines and is actively maintained with recent security fixes and broad standards support.

RATING: 9.5/10 MAINT: active DRIFT: low
▸ 4 reusable components found
tqdm/tqdm ★ 31352 3219 APPLICATION

tqdm is a fast, extensible progress bar library for Python and CLI. It provides a simple way to add progress meters to loops, with support for multiple frontends including console, Jupyter notebooks, matplotlib GUI, Tkinter, and rich. The core implementation in `tqdm/std.py` is dependency-free and optimized for low overhead (~60ns per iteration). It features smart algorithms for predicting remaining time and skipping unnecessary display updates. The library integrates with pandas, keras, dask, asyncio, and concurrent.futures. The CLI mode allows piping data through tqdm for progress monitoring. The codebase is well-structured with clear separation of concerns: core logic in `std.py`, frontends in separate modules (`notebook.py`, `gui.py`, `tk.py`, `rich.py`), and integrations in `contrib/`. Extensive test suite covers performance, correctness, and edge cases. The project is actively maintained with regular releases and CI.

RATING: 9.4/10 MAINT: active DRIFT: low
▸ 5 reusable components found
danielgatis/rembg ★ 25039 2438 APPLICATION

Rembg is a production-grade tool for removing image backgrounds, usable as a Python library, CLI, HTTP server, or Docker container. It wraps multiple ONNX-based segmentation models (U2Net, BiRefNet, SAM, BRIA-RMBG, etc.) and provides several cutout strategies: naive, alpha matting, color decontamination, and ViTMatte refinement. The architecture is modular: a session abstraction handles model download and inference, while the `remove()` function in `rembg/bg.py` orchestrates preprocessing, mask prediction, and post-processing. The CLI offers subcommands for single files (`i`), batch processing (`p`), HTTP serving (`s`), binary stream input (`b`), model download (`d`), and legacy migration (`m`). The HTTP server uses FastAPI with a Gradio UI and includes security measures like DNS rebinding protection. The codebase is well-tested, with synthetic fixtures for color decontamination and integration tests using perceptual hashing. It demonstrates strong engineering practices: idempotent migration, session caching, and careful handling of edge cases like oversized uploads and failed alpha matting convergence.

RATING: 9.4/10 MAINT: active DRIFT: low
▸ 5 reusable components found
has2k1/plotnine ★ 4770 258 APPLICATION

plotnine is a mature Python library that implements the Grammar of Graphics, closely modeled after R's ggplot2. It provides a declarative, layered API for building statistical visualizations: users compose plots by adding geometric objects (geoms), statistical transformations (stats), scales, coordinate systems, facets, themes, and guides using the `+` operator. The library renders all output through matplotlib, supporting a wide range of plot types (scatter, bar, line, histogram, density, boxplot, violin, contour, maps, etc.) with extensive customization via themes and scales. It includes built-in example datasets, animation support, plot composition (arranging multiple plots), and integration with Jupyter/Quarto. The codebase is well-structured with a clear separation of concerns (geoms, stats, scales, coords, facets, themes, guides, composition) and employs several reusable design patterns such as a registry metaclass for automatic subclass registration, dataclass-based scale definitions, a hierarchical themeable system, and a docstring generation decorator. External dependencies include matplotlib, pandas, numpy, scipy, statsmodels, mizani, and contourpy, with optional support for adjustText, geopandas, and skmisc. The project is actively maintained with weekly CI tests against bleeding-edge dependencies and a comprehensive test suite using baseline image comparison.

RATING: 9.4/10 MAINT: active DRIFT: low
▸ 4 reusable components found
ultrajson/ultrajson ★ 4496 385 APPLICATION

UltraJSON is a high-performance JSON encoder/decoder library for Python, implemented entirely in C with Python bindings. It provides drop-in replacements for Python's standard json module (ujson.dumps, ujson.loads, ujson.dump, ujson.load) and offers configuration options for ASCII encoding, HTML character escaping, forward slash escaping, indentation, sorting keys, NaN/Infinity handling, and customizable separators. The library's core architecture consists of a hand-optimized C state machine for decoding and a recursive encoder that handles Python objects via a type-context system. It bundles a copy of the double-conversion library for precise floating-point serialization and uses a stack-first, heap-later buffer allocation strategy. Despite being in maintenance-only mode due to architectural security concerns, the codebase exhibits strong craftsmanship: meticulous memory management, comprehensive UTF-8 validation, support for surrogate pairs, fuzz testing with ref-count verification, and compatibility with CPython's free-threaded builds. The repository also includes extensive tests, benchmarks, and CI for multiple architectures and Python implementations (CPython, PyPy, GraalPy).

RATING: 9.4/10 MAINT: active DRIFT: low
▸ 2 reusable components found
$ loading more...
$ submit: