On Tue, 16 Aug 2011 12:35:48 +1000 Nick Coghlan <ncogh...@gmail.com> wrote: > On Tue, Aug 16, 2011 at 11:30 AM, antoine.pitrou > <python-check...@python.org> wrote: > > +Serializing "pseudo-global" objects > > +----------------------------------- > > + > > +Objects which are not module-global, but should be treated in a similar > > +fashion -- such as methods [4]_ or nested classes -- cannot currently be > > +pickled (or, rather, unpickled) because the pickle protocol does not > > +correctly specify how to retrieve them. One solution would be through the > > +adjunction of a ``__namespace__`` (or ``__qualname__``) to all class and > > +function objects, specifying the full "path" by which they can be > > retrieved. > > +For globals, this would generally be ``"{}.{}".format(obj.__module__, > > obj.__name__)``. > > +Then a new opcode can resolve that path and push the object on the stack, > > +similarly to the GLOBAL opcode. > > + > > I think this is the part that ties in with the pickle-related aspects > for PEP 395 - using '__qualname__' would be one way to align a > module's real name with where it should be retrieved from and where > it's documentation lives (I like 'qualified name' as a term, too).
Oops, I admit I hadn't read PEP 395. PEP 395 focuses on module aliasing, while the suggestion above focuses on the path of objects in modules. How can we reconcile the two? Do we want __qualname__ to be a relative "path" inside the module? (but then __qualname__ cannot specify its own module name). Regards Antoine. _______________________________________________ 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