By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,203 Members | 935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,203 IT Pros & Developers. It's quick & easy.

Pickling/unpickling extensions types

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Bob <te*******@yahoo.com> writes:
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":
1() Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'int' object is not callable id(id)

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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.