3 ms·
> import numpy as np > np.linalg.inv(np.random.rand(4,4)) Which of course is nothing to do with python, and is trivially reduced to the aformentioned `inv(ran
by orf 6y ago
> import numpy as np
> np.linalg.inv(np.random.rand(4,4))
Which of course is nothing to do with python, and is trivially reduced to the aformentioned `inv(rand(4, 4))` with imports.
> And you have to write it like this, because of lack of dynamic dispatch.
Not at all.
- adamnemecek 6y agoBut you shouldn't be doing the imports and no one does it like it. You shouldn't import it into the global namespace because you can't dispatch on the type so you need to refer to it by the full name.
- orf 6y agoWell, not really, no. You shouldn't import into the global namespace for clarity - "from numpy import *" is very unclear. But importing specific objects is fine and is done all the time. And if you're in a notebook setting and value "less typing" over everything else it's certainly encouraged. Dynamic dispatch would help if you also defined a "rand" function in scope, but that's a way more general argument and IMO you'd lose more than you gain with it.
- adamnemecek 6y agoOK but the imports don't same much typing.