v0.5.10
Added
@impl
now has optional bool keyword argumentdetach
. If True, this will create a weak-reference finalizer for the method being implemented, and detach the method from the type when the method is garbage collected. If an original attribute exists, it will be restored during finalization, otherwise the attribute is deleted.- This can be useful in cases where methods are not safe to be kept through interpreter shutdown, like
int.__hash__
from einspect import impl, orig
@impl(int, detach=True)
def __hash__(self):
print("in hash", self)
return orig(int).__hash__(self)
Full Changelog: v0.5.9...v0.5.10