Make more things into properties.
A lot of the expensive getters were transformed into cached properties instead. A lot of things that were properties were transformed into properties as well.
This commit is contained in:
@ -31,6 +31,21 @@ from base64 import b64encode
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
|
||||
class cached_property:
|
||||
def __init__(self, function):
|
||||
self.function = function
|
||||
self.__doc__ = getattr(function, '__doc__')
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
if instance is None:
|
||||
return self
|
||||
|
||||
value = self.function(instance)
|
||||
setattr(instance, self.function.__name__, value)
|
||||
|
||||
return value
|
||||
|
||||
def parse_time(timestamp):
|
||||
if timestamp:
|
||||
return datetime.datetime(*map(int, re_split(r'[^\d]', timestamp.replace('+00:00', ''))))
|
||||
|
Reference in New Issue
Block a user