Pickling/unpickling extensions types

Discussion in 'Python' started by Bob, Sep 11, 2003.

  1. Bob

    Bob Guest

    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
    Bob, Sep 11, 2003
    #1
    1. Advertising

  2. Bob <> 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
    Martin v. =?iso-8859-15?q?L=F6wis?=, Sep 11, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    330
  2. Alex
    Replies:
    9
    Views:
    366
  3. Erwin S. Andreasen
    Replies:
    3
    Views:
    316
    Erwin S. Andreasen
    Feb 24, 2006
  4. Replies:
    3
    Views:
    295
    Peter Hansen
    Apr 6, 2006
  5. Littlefield, Tyler
    Replies:
    7
    Views:
    122
    mblume
    Apr 6, 2013
Loading...

Share This Page