Object1 in the local coordinate system of Object2
To get the matrix of ob1 in the local space of ob2

mwi = ob2.matrix_world.inverted()
m_local2ob2 = mwi * ob1.matrix_world

loc = m_local2ob2.to_translation() # local loc
loc, rot, scale = m_local2ob2.decompose()