Re:No-op statements syntactically valid only since Python X.Y
by eesmith on Tuesday June 07, 2022 @07:56AM
(#31652837)
While my observation is that most other Python packages don't import all subpackages.
"import urllib" does not also import urllib.parse, so you can't do:
import urllib
urllib.parse.quote("A&W")
but instead must explicitly import urllib.parse.scikit-learn supports essentially the same use cases as NumPy and it doesn't import all its subpackages:
>>> import sklearn
>>> sklearn.linear_model
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'sklearn' has no attribute 'linear_model'
>>> import sklearn.linear_model
>>> sklearn.linear_model
<module 'sklearn.linear_model' from '[...]sklearn/linear_model/__init__.py'>
Thus leading to my earlier comment:> The NumPy developers think "practicality beats purity" is more important, and their main use-case is long-running programs where startup costs are slow, which I interpret as meaning their special cases is special enough to break the rules.
However, what I'd say is that a short launch from rest is an even more obscure use case than the one numpy supports.
numpy has made the correct compromise IMO, optimizing for long lived programs and notebooks.