How to Decompose and Compose the local transform matrix
Using the 3x3 matrix rotation part.
Does a child object inherit the matrix from the parent?
Can decompose a matrix via Matrix.decompose()
loc, rot, scale = M.decompose()

the rotation is given as a quaternion.  There is no guarantee that that the same rotation matrix will be returned when converting that quaternion back to a matrix.  https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Rotation_matrix_%E2%86%94_quaternion
Test script, with both &quot;standard&quot; quaternion decompose and using the 3x3 rotation matrix part.
import bpy
from mathutils import Matrix

ob = bpy.context.object
# basis (or local) matrix
Mb = ob.matrix_local

print(&quot;Input&quot;)
print(Mb)


t, q, s = Mb.decompose()

T = Matrix.Translation(t)

R = q.to_matrix().to_4x4()

S = Matrix.Diagonal(s.to_4d())

M = T @ R @ S
print(&quot;Quaternion decompose&quot;)
print(M)

print((M.to_3x3() - Mb.to_3x3()).determinant())

R = Mb.to_3x3().normalized().to_4x4()

T = Matrix.Translation(
        Mb.to_translation()
        )

S = Matrix.Diagonal(
        Mb.to_scale().to_4d()
        )
        
M = T @ R @ S

print(&quot;3 x 3 decompose&quot;)
print(M)

print((M.to_3x3() - Mb.to_3x3()).determinant())

Sample output.
Input
&lt;Matrix 4x4 (1.8334, -0.5595,  0.0113, 0.6324)
            (0.5749,  0.1069, -0.9128, 2.6868)
            (6.2012,  1.4492,  0.3085, 0.8749)
            (0.0000,  0.0000,  0.0000, 1.0000)&gt;
Quaternion decompose
&lt;Matrix 4x4 ( 4.5809, -1.0592, -0.1913, 0.6324)
            (-1.7931, -0.0093, -0.9261, 2.6868)
            ( 4.2364,  1.1414, -0.1851, 0.8749)
            ( 0.0000,  0.0000,  0.0000, 1.0000)&gt;
0.6159369945526123
3 x 3 decompose
&lt;Matrix 4x4 (1.8334, -0.5595,  0.0113, 0.6324)
            (0.5749,  0.1069, -0.9128, 2.6868)
            (6.2012,  1.4492,  0.3085, 0.8749)
            (0.0000,  0.0000,  0.0000, 1.0000)&gt;
0.0