Cache field attributes list on the playbook classes (#79091)

* Cache field attributes list on the playbook classes
pull/79103/head
Martin Krizek 2 years ago committed by GitHub
parent 1286b7d42e
commit 58637702b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- Cache field attributes list on the playbook classes

@ -10,6 +10,7 @@ import operator
import os import os
from copy import copy as shallowcopy from copy import copy as shallowcopy
from functools import cache
from jinja2.exceptions import UndefinedError from jinja2.exceptions import UndefinedError
@ -74,7 +75,14 @@ class FieldAttributeBase:
@classmethod @classmethod
@property @property
def fattributes(cls): def fattributes(cls):
# FIXME is this worth caching? return cls._fattributes()
# mypy complains with "misc: Decorated property not supported"
# when @property and @cache are used together,
# split fattributes above into two methods
@classmethod
@cache
def _fattributes(cls):
fattributes = {} fattributes = {}
for class_obj in reversed(cls.__mro__): for class_obj in reversed(cls.__mro__):
for name, attr in list(class_obj.__dict__.items()): for name, attr in list(class_obj.__dict__.items()):

Loading…
Cancel
Save