mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #35270 -- Optimized model's Options._property_names.
co-authored-by: Nick Pope <nick@nickpope.me.uk>
This commit is contained in:
parent
73df8b54a2
commit
faeb92ea13
@ -1,6 +1,5 @@
|
|||||||
import bisect
|
import bisect
|
||||||
import copy
|
import copy
|
||||||
import inspect
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
@ -969,11 +968,13 @@ class Options:
|
|||||||
@cached_property
|
@cached_property
|
||||||
def _property_names(self):
|
def _property_names(self):
|
||||||
"""Return a set of the names of the properties defined on the model."""
|
"""Return a set of the names of the properties defined on the model."""
|
||||||
names = []
|
names = set()
|
||||||
for name in dir(self.model):
|
for klass in self.model.__mro__:
|
||||||
attr = inspect.getattr_static(self.model, name)
|
names |= {
|
||||||
if isinstance(attr, property):
|
name
|
||||||
names.append(name)
|
for name, value in klass.__dict__.items()
|
||||||
|
if isinstance(value, property)
|
||||||
|
}
|
||||||
return frozenset(names)
|
return frozenset(names)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
Loading…
Reference in New Issue
Block a user