Deserializing specific objects from a file

Discussion in 'Python' started by Aaron J. M., Sep 19, 2007.

  1. Aaron J. M.

    Aaron J. M. Guest

    I'm building a game and am starting to seriously think about
    serialization, though I haven't done much serialization before except
    for a few experiments with the pickle module.

    There are many objects that I want be able to move in and out of
    memory at runtime; namely the game levels. I only want one level in
    memory at a time, so I want to be able to unpickle specific Level
    objects as the player moves between levels. I would prefer my
    serialized objects to reside in one file.

    I haven't come across references that say how to do something like
    what I'm describing. Does anyone here know what techniques I have to
    employ here?

    Thank you,

    Aaron J. M.

    P.S. Is it *deserialize* or *unserialize*?
     
    Aaron J. M., Sep 19, 2007
    #1
    1. Advertising

  2. On Tue, 18 Sep 2007 16:02:38 -0700, Aaron J. M. wrote:

    > There are many objects that I want be able to move in and out of
    > memory at runtime; namely the game levels. I only want one level in
    > memory at a time, so I want to be able to unpickle specific Level
    > objects as the player moves between levels. I would prefer my
    > serialized objects to reside in one file.
    >
    > I haven't come across references that say how to do something like
    > what I'm describing. Does anyone here know what techniques I have to
    > employ here?


    Take a look at the `shelve`-Module. Another option might be pickling to
    individual files and store them in a ZIP archive.

    Ciao,
    Marc 'BlackJack' Rintsch
     
    Marc 'BlackJack' Rintsch, Sep 19, 2007
    #2
    1. Advertising

  3. Aaron J. M.

    Aaron J. M. Guest

    That's exactly what I needed. Thank you.

    Aaron J. M.
     
    Aaron J. M., Sep 19, 2007
    #3
    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. PJ
    Replies:
    1
    Views:
    1,803
    Ramzey
    Jun 25, 2003
  2. ce
    Replies:
    2
    Views:
    4,004
  3. Chris Newby
    Replies:
    0
    Views:
    428
    Chris Newby
    May 16, 2005
  4. =?Utf-8?B?U3RldmUgQnVnZGVu?=

    Problem deserializing file from asp.net

    =?Utf-8?B?U3RldmUgQnVnZGVu?=, Aug 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    475
    =?Utf-8?B?U3RldmUgQnVnZGVu?=
    Aug 21, 2005
  5. Andrew Lee
    Replies:
    2
    Views:
    3,126
    Andrew Lee
    Nov 18, 2004
Loading...

Share This Page