[zope2-tracker] [Bug 597594] [NEW] Optimise maybeWarnDeprecated

Christian Zagrodnick cz at gocept.com
Wed Jun 23 05:00:41 EDT 2010


Public bug reported:

OFS.subscriber.maybeWarnDeprecated checks if a deprecation warning
should be sent.

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 deprecatedManageAddDeleteClasses:
        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.ObjectManager.ObjectManager.

(I noticed that during test setup where various DirectoryViews are
created; the run time drops from 180s to 2s)

Anyone seconding that?

** Affects: zope2
     Importance: Low
         Status: New

-- 
Optimise maybeWarnDeprecated
https://bugs.launchpad.net/bugs/597594
You received this bug notification because you are a member of Zope 2
Developers, which is subscribed to Zope 2.


More information about the zope2-tracker mailing list