How to calculate a parent inverse matrix? Say I want to parent the default Cube to the camera from python without using an operator.

First part is easy:

Cube = bpy.data.objects['Cube']
Camera = bpy.data.objects['Camera']

Cube.parent = Camera


Now I want the cube to remain in place like it would if I used the operator. I assume I have to perform an operation on one of the camera's matrices and assign the result to the cube's matrix_parent_inverse, but what operation would it be?
Oh wow, that was embarrassingly easy.

Cube.matrix_parent_inverse = Cam.matrix_local.inverted