Why we don't use `from fastai import *` any more?

Although in videos we occasionally have seen the use of from fastai import *, the updated notebooks seem not use from fastai import * any more.

Just for curiosity, I explored what exactly inside from fastai import *, and it turns out that there is almost nothing included from fastai library.

first of all, let’s see the source code behind when we do import fastai, all we got is fastai.version.__version__, see below

then, let’s try from fastai import *, and check out dir(), we can see there is of course nothing useful from fastai library

According to the recent notebooks, it seems that the recommended usage of import is something like the following

from fastai.vision import *
from fastai.text import *

why? because each submodule like fastai.vision has contained all the libraries needed for it to work on its own, let’s see its source code

2 Likes