On 28/08/18 02:53, boB Stepp wrote:

> Wouldn't a single JSON file be wasteful?  If I used this program for a
> couple of years or so and habitually played a lot of solitaire, that
> would be a lot of stuff to load into RAM when on any given solitaire
> session I might only play one to three kinds of solitaire.  

It shouldn't be any more wasteful than if you used separate files.
Either you have to load up every file you ever saved or you have
some criteria that prevents you loading all of them. The same
with a JSON file. Either you load every record in the file or
you have some criteria that lets you load a subset.

You might want to eventually have some kind of archive
function that offloads old games to a separate file, just to
keep initial load times down but that's probably not an issue
in the short term.

> perhaps I am misunderstanding JSON's capabilities as I only have a
> cursory knowledge of it from considering it for other projects.

Think of it like a file based dictionary. You only instantiate
the objects you need. You load objects based on the key.

How you identify which objects you need at startup is the clever
bit. You haven't told us enough about your workflow for us to
suggest a solution there. But the same issue applies whether
you use separate files per game or session or a single JSON file.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to