memoized_property
A simple python decorator for defining properties that only run their fget function once.
Free software: BSD license
What?
A Python property that only calls its fget function one time. How many times have you written this code (or similar)?
def class C(object):
@property
def name(self):
if not hasattr(self, '_name'):
self._name = some_expensive_load()
return self._name
I’ve written it just enough times to be annoyed enough to capture this module. The result is this:
from memoized_property import memoized_property
def class C(object):
@memoized_property
def name(self):
# Boilerplate guard conditional avoided, but this is still only called once
return some_expensive_load()
Why?
I couldn’t find a pre-existing version of this on PyPI. I found one other on GitHub, https://github.com/ytyng/python-memoized-property, but it was not published to PyPI.
History
1.0.3 (2016-09-28)
Build universal wheels
Support Python 3.4, 3.5
1.0.2 (2014-05-02)
Remove dependency on six
1.0.1 (2014-01-01)
Added python 3.2 compatability
1.0.0 (2013-12-26)
First release on PyPI.
Metadata
Release files for memoized-property 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memoized-property-1.0.3.tar.gz | 5.0 kB | Without provenance | Details for memoized-property-1.0.3.tar.gz |
Release files / memoized-property-1.0.3.tar.gz
| Download URL | memoized-property-1.0.3.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4be4d0209944b9b9b678dae9d7e312249fe2e6fb8bdc9bdaa1da4de324f0fcf5
|
|
BLAKE2b-256 checksum How to use checksums |
70db23f8b5d86c9385299586c2469b58087f658f58eaeb414be0fd64cfd054e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for memoized-property 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.