[Python-Dev] [Python-checkins] peps: Add Alexandre's suggestions (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Tue Aug 16 04:35:48 CEST 2011


On Tue, Aug 16, 2011 at 11:30 AM, antoine.pitrou <python-checkins at 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).

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list