Serial- A serialization library (Who would have guessed?)
Posted: Wed Jun 22, 2011 2:15 am
I was looking around, and I couldn't find a good serialization library. Obviously I didn't look very hard, because I found TSerial five minutes after I finished writing this, but that isn't the point. Somebody is probably going to comment "oh, somebody else's library does this this and this and is 5x as fast", but oh well.
Serial is a serialization library that is optimized to run on large arrays of data (>200 elements, perhaps levels for a game or something?). It serializes to runnable Lua script, which you can (though the assert should never fail, and you can customize the function it creates).
Download at Github
edit: I keep finding things I forgot to post... If there is a userdata element in your array, it will first attempt to use the metamethod __serialize to serialize it, but if that does not exist, fall back to __tostring (Assuming you can somehow parse back out the data yourself), and if it can't find that, it will error.
edit: Did a few more tests, a few updates. Changed out table.insert with directly changing buffer... Did a test on 2^16 elements versus tserial... 8500% faster. (0.2 seconds versus 35!)
Serial is a serialization library that is optimized to run on large arrays of data (>200 elements, perhaps levels for a game or something?). It serializes to runnable Lua script, which you can
Code: Select all
assert(loadstring(serializedTable))() tableName = deserialize()
Download at Github
edit: I keep finding things I forgot to post... If there is a userdata element in your array, it will first attempt to use the metamethod __serialize to serialize it, but if that does not exist, fall back to __tostring (Assuming you can somehow parse back out the data yourself), and if it can't find that, it will error.
edit: Did a few more tests, a few updates. Changed out table.insert with directly changing buffer... Did a test on 2^16 elements versus tserial... 8500% faster. (0.2 seconds versus 35!)