How is a Child Of bone constraint carried out in terms of matrix operations?

From what I’ve tried to understand so far, it has something to do with the offset between the constraint’s inverse matrix and the target bone’s matrix, which is then applied to the owner bone’s matrix. However, I have no idea what set and order of operations and functions (@, inverted(), etc.) will achieve an equivalent result in Python.