I've admittedly gotten a little lost wading through the source for #Numpy (https://github.com/numpy/numpy), so I thought I'd ask anyone with better familiarity with the internals.
In Numpy, you can do something like
import numpy as np
x = np.linalg.solve(np.array([[1, 1], [3, 5]]), np.array([-1, 2]))
or even
np.linalg.solve(np.array([[1, 2], [3, 5]]), np.array([1, 2+3j]))
and Numpy is smart enough to figure out what the array type of the result ought to be, despite the mixed nature of the input. Which (internal?) function(s) are doing the appropriate type conversions behind the scenes, so that one gets the appropriate result?
I need operations like this for an algorithm I am trying to implement, and I thought it best to not reinvent the wheel.
(Otherwise, how do other Python libraries handle mixed types sanely?)