#NEWLINE# def per_instance( * args , **kwargs ) : #NEWLINE# #INDENT# "A memoized key factory that works like `equal_args` except that the first parameter's identity\n  is used when forming the key.\n\n  This is a useful key factory when you want to enforce memoization happens per-instance for an\n  instance method in a class hierarchy that defines a custom `__hash__`/`__eq__`.\n  " #NEWLINE# instance = args [ 0 ] #NEWLINE# unique_retained_instance = ( id ( instance ) , instance ) #NEWLINE# instance_and_rest = ( ( unique_retained_instance , ) + args [ 1 : ] ) #NEWLINE# return equal_args ( * instance_and_rest , ** kwargs )