@staticmethod
def patch(method, replacement, class_=None):
    """This method replaces m_method with a p_replacement method, but
           keeps p_method on its class under name
           "_base_<initial_method_name>_". In the patched method, one may use
           Hack.base to call the base method. If p_method is static, you must
           specify its class in p_class_."""
    isStatic = class_
    class_ = class_ or method.im_class
    name = isStatic and method.func_name or method.im_func.__name__
    baseName = '_base_%s_' % name
    if isStatic:
        method = staticmethod(method)
        replacement = staticmethod(replacement)
    setattr(class_, baseName, method)
    setattr(class_, name, replacement)
