Deserializing specific objects from a file

A

Aaron J. M.

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*?
 
M

Marc 'BlackJack' Rintsch

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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top