On Thu, Jul 23, 2009 at 12:09 PM, Fred Drake<fdr...@acm.org> wrote: > On Jul 23, 2009, at 2:59 PM, Georg Brandl wrote: >> >> is the presence of None values in sys.modules considered an implementation >> detail? If not, it should be documented what the None values mean to the >> interpreter. > > As I recall, they're an optimization. But since sys.modules is itself > documented, and many applications actually use it, I think it's worth > explaining that the None values can reasonably be expected, and what they > indicate.
They should certainly be documented -- without them imports from inside package would be super expensive (at least for Python versions where implicit relative import exists). I'm somewhat surprised this isn't documented, I don't think I've tried to keep this usage hidden. I've also sometimes abused this to force some module to believe that a certain other module doesn't exist. OTOH in Py3k I'm not sure that we even *need* them any more, since there is no more implicit relative import... They would only speed up the raising of ImportError, not the finding of a similar-named module elsewhere in the hierarchy. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com