def per_instance(*args, **kwargs):
 instance = args[0]
 unique_retained_instance = (id(instance), instance)
 instance_and_rest = ((unique_retained_instance,) + args[1:])
 return equal_args(*instance_and_rest, **kwargs)

def per_instance ( * args , ** kwargs ) : instance = args [ 0 ] unique_retained_instance = ( id ( instance ) , instance ) instance_and_rest = ( ( unique_retained_instance , ) + args [ 1 : ] ) return equal_args ( * instance_and_rest , ** kwargs )
a memoized key factory that works like equal_args except that the first parameters identity is used when forming the key .