Skip to main content

A cached-property decorator.

Project description

Cached Property

This module adds a decorator cached_property and a function drop_cache.

Example

from cached_property import cached_property, drop_cache
import time

class Dummy:
    @cached_property
    def the_answer(self):
        time.sleep(0.5)
        return 42

dummy = Dummy()
t0 = time.time()
err = dummy.the_answer
dt = time.time()-t0
print(dt)
# dt -> ~0.5 seconds
t0 = time.time()
err = dummy.the_answer
dt = time.time()-t0
print(dt)
# dt -> ~1e-6 seconds
drop_cache(dummy, 'the_answer')
t0 = time.time()
err = dummy.the_answer
dt = time.time()-t0
print(dt)
# dt -> ~0.5 seconds

License and Copyright

Copyright 2019 Brain Electrophysiology Laboratory Company LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this module or the code within it except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Project details


Download files

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

Source Distribution

cached_property_bel-1.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

cached_property_bel-1.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file cached_property_bel-1.0.1.tar.gz.

File metadata

  • Download URL: cached_property_bel-1.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cached_property_bel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9d0db437ceaf0ebb734b962581cd17d949f497e88d94ad342779a9093e40b6ef
MD5 7ed58eff7227f406e5313e280b8c472c
BLAKE2b-256 f10181435405fadeb421d6c72c39d92e491513e5ac3ca67520c7f152cf0c62c5

See more details on using hashes here.

File details

Details for the file cached_property_bel-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cached_property_bel-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cached_property_bel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9ad14ad6f95e81871ec4aec27ab91f9b0beebcd1ce6c17a1f00bee7c2d9d3a
MD5 f33dd58c711b1bb183f9a94167f37c03
BLAKE2b-256 86e29b8c9a3a4597b57fd0894c57cfc284497a97291fd39c779d31bfffa0c862

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page