Ser: a new old serialization library

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ivan
Party member
Posts: 1137
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Ser: a new old serialization library

Post by ivan » Tue Aug 11, 2015 4:54 pm

For example:

Code: Select all

f = io.open('out.txt', 'w')
f:write(string.format("%.17g\n", 1))
f:write(string.format("%.17g\n", 1/2))
f:write(string.format("%.17g\n", 1/3))
f:write(string.format("%.17g\n", 1/4))
f:write(string.format("%.17g\n", 1/5))
Outputs:

Code: Select all

1
0.5
0.3333333432674408
0.25
0.20000000298023224
Not a major issue since with 32-bit floats it would just be truncated during loading.
I guess it could lead to imprecision when the serialization output from a 32 bit distribution is used with a 64 bit distribution (which is not supposed to happen anyways).
Again, it's a minor thing so I wouldn't be too worried about it.

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Ser: a new old serialization library

Post by Robin » Fri Aug 14, 2015 9:57 am

Yeah, I think the only downside is that slightly more bytes than needed will be used for 32-bit builds, but that's a trade-off I'm willing to make for maintainability, especially because I don't think Ser will be used often with those builds.
Help us help you: attach a .love.

User avatar
ivan
Party member
Posts: 1137
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Ser: a new old serialization library

Post by ivan » Fri Nov 10, 2017 7:10 am

Hi Robin,I still use "ser" in several projects/tools and it works great.
However, I have recently noticed something:

Code: Select all

local pairs, ipairs, tostring, type, concat, dump, floor, format = pairs, ipairs, tostring, type, table.concat, string.dump, math.floor, string.format
Testing with LuaJIT suggests that it's actually faster to avoid the first four locals:

Code: Select all

local concat, dump, floor, format = table.concat, string.dump, math.floor, string.format
There is no difference in performance with vanilla Lua.

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests