Page 3 of 3

Re: Ser: a new old serialization library

Posted: Tue Aug 11, 2015 4:54 pm
by ivan
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.

Re: Ser: a new old serialization library

Posted: Fri Aug 14, 2015 9:57 am
by Robin
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.

Re: Ser: a new old serialization library

Posted: Fri Nov 10, 2017 7:10 am
by ivan
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.