nitorch
nitorch copied to clipboard
API: batch import or user import?
-
torch
import all submodules when performingimport nitorch
. That is, we then have access to, e.g.,nitorch.nn
without having to import it. This is because__init__.py
exposes (=imports) all submodules. - Conversely, in
scikit-learn
, each submodule must be specifically imported by the user, e.g.,import sklearn.ensemble
.
The first one is more 'ease-of-use' oriented, while the second one is more 'performance-oriented' (as imports actually 'cost' something).
What should we do @brudfors?
Personally, I prefer (if I understood the question correctly), e.g.:
from nitorch.utils import softmax
I like the look of it and that you have access to the function without having to call its namespace. If that is also better from a performance point of view, then maybe that settles it?