Skip to main content
https://travis-ci.com/penguinolog/backports.cached_property.svg?branch=master https://img.shields.io/pypi/v/backports.cached-property.svg https://img.shields.io/pypi/pyversions/backports.cached-property.svg https://img.shields.io/pypi/status/backports.cached-property.svg https://img.shields.io/github/license/penguinolog/backports.cached_property.svg https://img.shields.io/badge/code%20style-black-000000.svg

What

Python 3.8 adds great descriptor to functools: cached_property. Technically all required APIs was available since python 3.6, but it is what it is.

This package is a backport of this functionality for python 3.6 and 3.7.

How to use

from backports.cached_property import cached_property

And then python 3.8 documentation will work (because code is minimally changed):

Transform a method of a class into a property whose value is computed once and then cached as a normal attribute for the life of the instance. Similar to property, with the addition of caching. Useful for expensive computed properties of instances that are otherwise effectively immutable.

Example:

class DataSet:
    def __init__(self, sequence_of_numbers):
        self._data = sequence_of_numbers

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

    @cached_property
    def variance(self):
        return statistics.variance(self._data)

Metadata

Release files for backports.cached-property 1.0.2

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

Source distribution (sdist)

Source distribution for backports.cached-property 1.0.2
File Size Uploaded
backports.cached-property-1.0.2.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for backports.cached-property 1.0.2
File Interpreter ABI Platform
backports.cached_property-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / backports.cached-property-1.0.2.tar.gz

Download URL backports.cached-property-1.0.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9306f9eed6ec55fd156ace6bc1094e2c86fae5fb2bf07b6a9c00745c656e75dd
BLAKE2b-256 checksum
How to use checksums
08834cea5c665d2af765c02f7d8e8560b5918405c1d7d11ccfc60c4919c1cfd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / backports.cached_property-1.0.2-py3-none-any.whl

Download URL backports.cached_property-1.0.2-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
baeb28e1cd619a3c9ab8941431fe34e8490861fb998c6c4590693d50171db0cc
BLAKE2b-256 checksum
How to use checksums
ebae69e52acdcf381b108b36d989ea58656de4a9ab8863aba6176d80d01041df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 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