A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/066824.html below:

[Python-Dev] Pickle implementation questions

[Python-Dev] Pickle implementation questions [Python-Dev] Pickle implementation questionsBruce Christensen t-bruch at microsoft.com
Fri Jun 30 19:16:54 CEST 2006
Thanks for your responses, Martin!

Martin v. Löwis wrote:
> Bruce Christensen wrote:
> >  - Where are object.__reduce__ and object.__reduce_ex__ defined, and how
> > does copy_reg._reduce_ex fit into the picture? 
> 
> See
> 
> http://docs.python.org/lib/node69.html

So just to be clear, is it something like this?

class object:
    def __reduce__(self):
        return copy_reg._reduce_ex(self, -1)

    def __reduce_ex__(self, protocol):
        return copy_reg._reduce_ex(self, protocol)

Does _reduce_ex's behavior actually change depending on the specified protocol version? The only difference that I can see or think of is that an assert causes it to fail if the protocol is >= 2.

> >  - What does copy_reg.constructor() do?
> 
> It does this:
> 
> def constructor(object):
>     if not callable(object):
>         raise TypeError("constructors must be callable")

So it is part of the public interface? It's exported in __all__, but it appears
that it's undocumented.

Thanks,

--Bruce
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4