Hi,
currently I'm using JSON for serializing spawn points in my Ultimate Deathmatch plugin. While this might be OK and doesn't really slow anything down since the files are only loaded on special occasians, they are not really readable and could very safely be saved in a binary format. Other than that the order of the file's contents could be preserved.
Now, my question is which options we have for SP. Converting everything using Pickle/cPickle would cause more code overhead than usage imho. Is there an easier way/library? How about Google's protobufs? Are they included in SP? - I read that word a couple times while looking up something in SP's source files, but I don't know if I could use protobufs in a plugin other than putting its source into a package or something.
Thanks for your answers!
Edit: Protobufs are probably too much overhead as well. But the question remains :)
Best way to serialize/deserialize data?
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Best way to serialize/deserialize data?
BackRaw wrote:Converting everything using Pickle/cPickle would cause more code overhead than usage imho. Is there an easier way/library?
I always liked the simplicity of shelve which does all the pickling for you from a dict-like object. Vector instances also have their own suite so they can be stored as is.
Re: Best way to serialize/deserialize data?
L'In20Cible wrote:BackRaw wrote:Converting everything using Pickle/cPickle would cause more code overhead than usage imho. Is there an easier way/library?
I always liked the simplicity of shelve which does all the pickling for you from a dict-like object. Vector instances also have their own suite so they can be stored as is.
Great! I totally forgot about shelve to be honest. How would I use the vector suit in a plugin?
- L'In20Cible
- Project Leader
- Posts: 1533
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Best way to serialize/deserialize data?
You don't have to do anything, was just pointing out that Vector instances can be pickled as is without conversion on your part:BackRaw wrote:L'In20Cible wrote:How would I use the vector suit in a plugin?
Syntax: Select all
with shelve.open('spawnpoints') as db:
db['de_dust2'] = [Vector(1, 2, 3), Vector(4, 5, 6)]
Re: Best way to serialize/deserialize data?
L'In20Cible wrote:You don't have to do anything, was just pointing out that Vector instances can be pickled as is without conversion on your part:BackRaw wrote:L'In20Cible wrote:How would I use the vector suit in a plugin?Syntax: Select all
with shelve.open('spawnpoints') as db:
db['de_dust2'] = [Vector(1, 2, 3), Vector(4, 5, 6)]
Oh, alright. Thanks!
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 13 guests