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.
Release files for cached-property-bel 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cached_property_bel-1.0.1.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cached_property_bel-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / cached_property_bel-1.0.1.tar.gz
| Download URL | cached_property_bel-1.0.1.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d0db437ceaf0ebb734b962581cd17d949f497e88d94ad342779a9093e40b6ef
|
|
BLAKE2b-256 checksum How to use checksums |
f10181435405fadeb421d6c72c39d92e491513e5ac3ca67520c7f152cf0c62c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / cached_property_bel-1.0.1-py3-none-any.whl
| Download URL | cached_property_bel-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d9ad14ad6f95e81871ec4aec27ab91f9b0beebcd1ce6c17a1f00bee7c2d9d3a
|
|
BLAKE2b-256 checksum How to use checksums |
86e29b8c9a3a4597b57fd0894c57cfc284497a97291fd39c779d31bfffa0c862
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|