Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Create properties that are only computed the first time they are called.

Project Description

Only compute the value of properties the first time they are called. The easiest way to explain it is by example.

Bad:

class Foo(object):
    def __init__(self):
        self._bar_cache = None

    @property
    def bar(self):
        if self._bar_cache is None:
            self._bar_cache = 2 * 2 * 2
        return self._bar_cache

Good:

from memoize import mproperty

class Foo(object):
    @mproperty
    def bar(self):
        return 2 * 2 * 2
Release History

Release History

This version
History Node

1.0.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
memoize-1.0.0.tar.gz (1.1 kB) Copy SHA256 Checksum SHA256 Source Jun 13, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting