Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Contributors
* Vadim Pushtaev (@VadimPushtaev)
* Martin Larralde (@althonos)
* Qudus Oladipo (@stikks)
* Sean Aubin (@seanny123)
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ replacement with fully compatible API (import ``property_cached`` instead of
``cached_property`` in your code and *voilà*). In case development resumes on
the original library, this one is likely to be deprecated.

*Original readme included below:*
*Slightly modified README included below:*

Why?
-----

* Makes caching of time or computational expensive properties quick and easy.
* Because I got tired of copy/pasting this code from non-web project to non-web project.
* I needed something really simple that worked in Python 2 and 3.

How to use it
--------------
Expand Down
21 changes: 2 additions & 19 deletions property_cached/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# -*- coding: utf-8 -*-

import asyncio
import functools
import pkg_resources
import sys
import threading
import weakref
from time import time

try:
import asyncio
except (ImportError, SyntaxError):
asyncio = None


__author__ = "Martin Larralde"
__email__ = "[email protected]"
Expand All @@ -27,17 +20,7 @@ class cached_property(property):
""" # noqa

_sentinel = object()

if sys.version_info[0] < 3:

def _update_wrapper(self, func):
self.__doc__ = getattr(func, "__doc__", None)
self.__module__ = getattr(func, "__module__", None)
self.__name__ = getattr(func, "__name__", None)

else:

_update_wrapper = functools.update_wrapper
_update_wrapper = functools.update_wrapper

def __init__(self, func):
self.cache = weakref.WeakKeyDictionary()
Expand Down