Get the overall size for each axis of the bounding box, then get the difference between the two objects’ bounding box size per axis, and multiply the scale of the object to modify by that value.

E.G:

```
import maya.cmds as mc
objA = mc.ls(sl=1)[0]
objB = mc.ls(sl=1)[1]
objA_BoundRaw = mc.xform(objA, q=1, bb=1)
objB_BoundRaw = mc.xform(objB, q=1, bb=1)
objA_Bound = [objB_BoundRaw[3]-objB_BoundRaw[0], objB_BoundRaw[4]-objB_BoundRaw[1], objB_BoundRaw[5]-objB_BoundRaw[2]]
objB_Bound = [objA_BoundRaw[3]-objA_BoundRaw[0], objA_BoundRaw[4]-objA_BoundRaw[1], objA_BoundRaw[5]-objA_BoundRaw[2]]
objBScaleOld = mc.xform(objB, q=1, s=1)
boundDifference = [objA_Bound[0]/objB_Bound[0], objA_Bound[1]/objB_Bound[1], objA_Bound[2]/objB_Bound[2]]
objBScaleNew = [objBScaleOld[0]*boundDifference[0], objBScaleOld[1]*boundDifference[1], objBScaleOld[2]*boundDifference[2]]
mc.xform(objB, scale=objBScaleNew)
```

This obviously isn’t the most optimised code by far, but it demonstrates the principle.