How is object transform matrix constructed in source

Sorry in advance guys I hope I posted in the correct category, I’m new here.

I was wondering about the way Blender constructs model matrices for objects. Blender exposes transform channels in the viewport which the user can tweak. Also object transform matrices are exposes via the python api like matrix_world. When assigning matrix_world directly through python, the viewport channels get the decomposed output values of this matrix. However we can also do the reverse operation, where we can tweak the channels and the transform matrix gets the updated value.

But what is the actual order of operations with which the finished model transform that is sent to graphic card is created?

What happens when we assign matrix_world attribute directly? Is the order of operations either:

matrix_world attribute -> decompose to viewport channels -> create OpenGL model matrix from channels (1)

matrix_world attribute -> use directly as model matrix -> retroactively decompose to viewport channels (2)