propcache

Fast, C-accelerated property caching for Python, providing `cached_property` and `under_cached_property` decorators

Library
PyPI
v0.5.4
36 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
70 /100 Good
Development Activity 92
Maintenance 96
Community 28
Maturity 44
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
68 /100 Good
Architecture 65
Code Quality 72
Innovation 55
Learning Curve 80

propcache provides a cached_property-style decorator that memoizes an expensive computed attribute on first access and reuses the result on subsequent lookups, with an optional Cython-compiled fast path for CPython and a pure-Python fallback for other interpreters like PyPy. It also offers under_cached_property, a variant that stores its cache under a name-mangled attribute to avoid clashing with __slots__ or public attribute names.

Extracted from the aio-libs ecosystem (the organization behind aiohttp, yarl, and multidict), propcache was split out as its own dependency so that performance-sensitive caching logic could be shared and independently versioned across those libraries and any other project needing the same pattern.

What You Get

  • cached_property decorator that memoizes a method’s result as an instance attribute on first access
  • under_cached_property variant storing the cache under a mangled name to coexist with __slots__
  • A Cython-compiled _helpers_c fast path used automatically on supported CPython builds
  • A pure-Python _helpers_py fallback so the library works unmodified on PyPy and other interpreters
  • Full type-hint support via a bundled py.typed marker for static type checkers

Common Use Cases

  • Caching expensive derived attributes (e.g. parsed URL components, computed hashes) on frequently instantiated objects
  • Reducing per-request overhead in high-throughput async libraries like aiohttp and yarl that call the same computed property repeatedly
  • Any Python class needing memoized properties without introducing a heavier caching framework as a dependency
  • Libraries needing memoization compatible with __slots__-based classes via under_cached_property

Under The Hood

Architecture The library exposes a stable public surface (api.py, __init__.py) that re-exports whichever implementation is available: a Cython-compiled extension built from _helpers_c.pyx when present, or the pure-Python _helpers_py.py implementation as an automatic fallback, with _helpers.py acting as the selection/compatibility shim between the two.

Tech Stack A hybrid Python/Cython project using a custom in-tree PEP 517 build backend (packaging/pep517_backend) to conditionally cythonize and compile the C extension at build time; ships prebuilt wheels for common platforms so most users never need a C compiler, and is packaged with a src/ layout.

Code Quality Despite its small size (roughly 250 lines across implementation files), the project has a proportionally thorough test suite (test_cached_property.py, test_under_cached_property.py, test_api.py, plus dedicated benchmark tests) and enforces mypy static typing via .mypy.ini, along with pre-commit hooks and towncrier-managed changelogs.

API Design The API is minimal by design — import cached_property and apply it exactly like Python’s standard-library functools.cached_property, making adoption immediate for anyone already familiar with that pattern, with under_cached_property as the only additional concept needed for __slots__ compatibility.

Used by 5 apps in this directory

Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 4 days ago
Python
70%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

29,650

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
91
Repo Health
91
Technical
63
Dependency
Built with
Python 70%
TypeScript 18%
Updated 6 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 2 weeks ago
Python
86%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,541

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
82
Repo Health
75
Technical
66
Dependency
Built with
Python 86%
HTML 14%
Updated 1 weeks ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,047

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
62
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers