2 ms·
Fwiw, I never use them in Python if I don't need to put anything inside them. They're optional for a reason.
by OutOfHere 2y ago
Fwiw, I never use them in Python if I don't need to put anything inside them. They're optional for a reason.
- dragonwriter 2y agoThey are "optional" because support was added for implicit namespace packages, but those have different semantics (particularly, placing another thing that resolves as a namespace package with the same name elsewhere on sys.path adds to the same package; as a result, the import machinery can't stop scanning sys.path when it finds a namespace package, it has to continue scanninng to see if there are more parts to add or if there is a standard package that takes precedence, so leaving off __init__.py for what is intended as a standard package, as well as opening up potentially incorrect behavior, adds a startup cost.)