pickle format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerome Alet

    pickle format

    I'd want to pickle a complex Python data structure and save it as
    a blob in a relationnal database.

    Now I do that, and I can retrieve it with no problem and then unpickle it.

    But if I upgrade Python some day, will I still be able to unpickle datas
    which were pickled with old versions and stored in my database ?

    If not, then is there another module which would be version independant ?

    Thanks in advance

    Jerome Alet

  • Paul Rubin

    #2
    Re: pickle format

    Jerome Alet <alet@librelogi ciel.com> writes:[color=blue]
    > But if I upgrade Python some day, will I still be able to unpickle datas
    > which were pickled with old versions and stored in my database ?[/color]

    Yes. At least, that is promised by the documentation.

    Comment

    • Jerome Alet

      #3
      Re: pickle format

      On Tue, 14 Oct 2003 15:23:21 -0700, Paul Rubin wrote:
      [color=blue]
      > Jerome Alet <alet@librelogi ciel.com> writes:[color=green]
      >> But if I upgrade Python some day, will I still be able to unpickle datas
      >> which were pickled with old versions and stored in my database ?[/color]
      >
      > Yes. At least, that is promised by the documentation.[/color]

      Sorry for not having checked then.

      Thanks a lot !

      bye

      Jerome

      Comment

      • Terry Reedy

        #4
        Re: pickle format


        "Jerome Alet" <alet@librelogi ciel.com> wrote in message
        news:pan.2003.1 0.14.22.19.50.4 44187@librelogi ciel.com...[color=blue]
        > I'd want to pickle a complex Python data structure and save it as
        > a blob in a relationnal database.
        >
        > Now I do that, and I can retrieve it with no problem and then[/color]
        unpickle it.[color=blue]
        >
        > But if I upgrade Python some day, will I still be able to unpickle[/color]
        datas[color=blue]
        > which were pickled with old versions and stored in my database ?[/color]

        In short, yes.

        Lib Ref 3.14.2 Data stream format

        There are currently 3 different protocols which can be used for
        pickling.

        Protocol version 0 is the original ASCII protocol and is backwards
        compatible with earlier versions of Python.

        Protocol version 1 is the old binary format which is also compatible
        with earlier versions of Python.

        Protocol version 2 was introduced in Python 2.3. It provides much more
        efficient pickling of new-style classes.

        Refer to PEP 307 for more information.
        -----
        From the PEP:
        To date, each release of Python has been able to
        read pickles written by all previous releases.

        Protocol 1 is kept precisely for this reason. I am sure that Guido
        intends for this to remain true at least thru the 2.x series. I
        believe this would only change if the Python object system were
        changed enough (in Python 3 or beyond) that unpickling old objects in
        the new system were to make no sense. If that were to happen, you
        would want to upgrade by addition rather than replacement.

        Terry J. Reedy


        Comment

        Working...