[PYTHON] Do not omit __init__.py

Many people are willing to omit __init__.py from Python 3.3, but ** don't. ** **

Why the misunderstanding happened

Starting with Python 3.3, the Implicit namespace package has been added in PEP 420.

** Namespace packages are not ordinary packages. ** It's a special purpose, and for most people ** you don't even need to know **.

If you really want to know, read PEP 420 above and the packaging guide.

The harmful effect of omitting __init__.py

Abusing the Implicit namespace package with a regular package is harmful.

import is slow

Since it is different from a normal package, import may be slow to find modules in the package. Also, although the probability is low, there may be some problems due to the difference in the search order.

Tool does not support

For example, the standard library unittest's ability to automatically search for test modules does not search in directories that do not have __init__.py. (See https://bugs.python.org/issue29642)

** If you try to do this, you will have to recursively search all directories that do not have __init__.py. That directory is node_modules and may contain hundreds of thousands of files and directories. How slow would it be if the directory were network mounted? ** **

Such slowdowns are simply unacceptable for users who abuse the Implicit namespace package as a regular package **. ** **

For the same reason, don't expect tools like lint to have the ability to automatically search for packages and modules to look for Implicit namespace packages.

There may be tools that accept and respond to requests without knowing the background, but do not send issues or pull requests that say "should respond" or "respond" because it is annoying to maintainers and other users. ..

Recommended Posts

Do not omit __init__.py
Do not switch with pyenv global!
[Matplotlib] Do not tilt the axis label