Pickling/unpickling extensions types

B

Bob

I've read over section 3.14.5.2 of the doc about a
zillion times, and it still makes absolutely no sense
to me. Can someone please explain it?

What I'd like to do is, basically, have the object be
pickled as None, since it represents an object in the
C world, and it doesn't make sense to pickle it at
all. How can I do that, if at all?

In particular, what does this

"A callable object, which in the unpickling
environment must be either a class, a callable
registered as a ``safe constructor'' (see below), or
it must have an attribute __safe_for_unpickling__ with
a true value. Otherwise, an UnpicklingError will be
raised in the unpickling environment. Note that as
usual, the callable itself is pickled by name"

mean?

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
 
M

Martin v. =?iso-8859-15?q?L=F6wis?=

Bob said:
In particular, what does this

"A callable object, which in the unpickling
environment must be either a class, a callable
registered as a ``safe constructor'' (see below), or
it must have an attribute __safe_for_unpickling__ with
a true value. Otherwise, an UnpicklingError will be
raised in the unpickling environment. Note that as
usual, the callable itself is pickled by name"

mean?

What part of it is it that you don't understand? A "callable object"
is one that you can call. E.g. X is callable, if X(some_arguments)
"works":
Traceback (most recent call last):
1076510860

So the builtin id is callable, the number 1 is not. Examples for
callable objects are functions, bound methods, classes, and objects
whose classes implement __call__.

For "safe constructors", see below in the text.

"Have an attribute" means that getattr works. An object X has an
attribute y if X.y "works".

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top