nitorch icon indicating copy to clipboard operation
nitorch copied to clipboard

API: batch import or user import?

Open balbasty opened this issue 4 years ago • 1 comments

  • torch import all submodules when performing import 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?

balbasty avatar Jun 09 '20 14:06 balbasty

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?

brudfors avatar Jun 10 '20 18:06 brudfors