mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +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 copy
|
||||
import inspect
|
||||
from collections import defaultdict
|
||||
|
||||
from django.apps import apps
|
||||
@ -969,11 +968,13 @@ class Options:
|
||||
@cached_property
|
||||
def _property_names(self):
|
||||
"""Return a set of the names of the properties defined on the model."""
|
||||
names = []
|
||||
for name in dir(self.model):
|
||||
attr = inspect.getattr_static(self.model, name)
|
||||
if isinstance(attr, property):
|
||||
names.append(name)
|
||||
names = set()
|
||||
for klass in self.model.__mro__:
|
||||
names |= {
|
||||
name
|
||||
for name, value in klass.__dict__.items()
|
||||
if isinstance(value, property)
|
||||
}
|
||||
return frozenset(names)
|
||||
|
||||
@cached_property
|
||||
|
Loading…
Reference in New Issue
Block a user