i propose the attached patch to change the rule to
define what container an object belongs to.
Currently an object defined in a .so module (it should
be a .pyd on Windows, but this wasn't checked) belongs
to it. Often the .so object is just an implementative
detail and python modules are used to shape the package
in its public form.
Of course often objects are imported from .so/.pyd
modules just to be used into the bodule and are not
part of the public api.
The patched version first checks if the object is
inside a .py module AND in its __all__ list: such
module has precedence on any .so/.pyc.
A second update is related to modules public/private
state. Currently modules are public only if they are
iported from another public module. Often this is not
the case: many packages are not made to be imported
interely, but present a tree structure and people can
use "import parent.child1.child2" effectively loading
only the required module.
The patch marks as "public" all the modules explicitely
specified on the command line, unless its name doesn't
start with an underscore.