[Python-checkins] peps: Add Alexandre's suggestions

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-checkins mailing list