Optimise maybeWarnDeprecated
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Low
|
Christian Zagrodnick |
Bug Description
OFS.subscriber.
There are two ways for classes to avoid the warning: ZCML and the __five_method__ attribute on the method.
maybeWarnDeprecated first checks the ZCML registered classes by iterating over a list:
for cls in deprecatedManag
if isinstance(ob, cls):
# Already deprecated through zcml
return
and then checking for __five_method__:
if getattr(getattr(ob, method_name), '__five_method__', False):
# Method knows it's deprecated
return
IMHO those two checks should be reversed: first check for the attribute, then for the ZCML registered: checking for the attribute is *much* faster and is hit by common cases where a class is just subclassing an OFS.ObjectManag
(I noticed that during test setup where various DirectoryViews are created; the run time drops from 180s to 2s)
Anyone seconding that?
Changed in zope2: | |
status: | Confirmed → In Progress |
Changed in zope2: | |
status: | Fix Committed → Fix Released |
Sounds good to me. Maybe adding a first path for checking direct types without subtypes could help as well, something like:
ob_type = type(ob) eAddDeleteClass es:
if ob_type in deprecatedManag
return
for cls in deprecatedManag eAddDeleteClass es:
if issubclass(ob_type, cls):
return