skillfed

backports.cached-property

cached_property() - computed once per instance, cached as attribute

backports-cached-property v1.0.2 509.4K downloads/30d#6,271 on PyPI15
Permissive license MIT License DORMANT released

What it is and what it does

This package backports Python 3.8's cached_property descriptor to Python 3.6 and 3.7. It lets you decorate a method so its result is computed once and then stored as a regular instance attribute, avoiding recomputation on subsequent accesses. The decorator is useful for expensive computed properties that don't change during an instance's lifetime.

The implementation is minimal and closely follows Python 3.8's standard library version. It depends only on the typing module and installs as a single wheel with low friction. However, it has a known limitation: it requires instances to have a mutable __dict__ attribute, so it won't work with classes that define __slots__ without including __dict__, or with metaclasses.

Use it for:

  • Add caching to expensive statistical computations in data analysis classes.
  • Backport cached_property to legacy codebases still running Python 3.6 or 3.7.
  • Cache derived attributes in immutable-like objects where recomputation is wasteful.
  • Simplify property definitions when you need both lazy evaluation and memoization.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides the cached_property decorator for Python 3.6 and 3.7, allowing methods to be computed once per instance and cached as attributes.

Yes, if you need cached_property on Python 3.6 or 3.7. The package is stable, permissively licensed, and has no known vulnerabilities. Dormant maintenance is acceptable here because the backport targets a fixed API from Python 3.8—there is little reason for it to change. If you are already on Python 3.8+, use the standard library instead.

Install

backports-cached-property on PyPI

pip

pip install backports-cached-property

uv

uv add backports-cached-property

poetry

poetry add backports-cached-property

Installing backports.cached-property

Before you install

Low install friction with a single wheel dependency. Maintenance is dormant—last release was 2022-06-14 and no commits since 2023-11-22—but the package is marked Production/Stable and addresses a narrow, stable backport use case.

License in practice

MIT License (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

pip install backports.cached-property

from backports.cached_property import cached_property

class DataSet:
    @cached_property
    def stdev(self):
        return statistics.stdev(self._data)

Requires Python 3.6 or later. Does not work with classes using __slots__ without __dict__, or with metaclasses.

Verify before relying

  • Whether dormant maintenance (last commit 2023-11-22) poses a risk for future Python versions beyond 3.9.
  • Real-world performance impact of caching overhead versus computation savings in typical use cases.

Package facts

License MIT License (permissive)
Python support supports the current Python release (>=3.6.0)
Install friction low — pure-Python wheel
Runtime dependencies 1 — typing
Maintenance dormant — 1,522 days since the last release
Last repo commit
First released
Downloads 509,434/month — #6,271 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: backports.cached_property-1.0.2-py3-none-any.whl

Keywords: caching, development

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

cached property decoratorproperty caching pythoncomputed property memoizationbackport cached_propertyinstance attribute cachingexpensive computation caching
backportperformance-optimization

More Python Modules packages