Re: [go-nuts] gob non-optimal serialization in case of interface

2021-04-05 Thread dev.nul...@gmail.com
Thanks everyone for the insights and suggestions. On Monday, 5 April 2021 at 13:47:20 UTC+8 Amnon wrote: > I would agree with Axel, that while gob is convenient, it never claims to > be optimal. > And if you care about size and speed of encoding then it may be worth > looking at > other serial

Re: [go-nuts] gob non-optimal serialization in case of interface

2021-04-04 Thread Amnon
I would agree with Axel, that while gob is convenient, it never claims to be optimal. And if you care about size and speed of encoding then it may be worth looking at other serialisation formats. See https://ugorji.net/blog/benchmarking-serialization-in-go for some alternatives On Sunday,

Re: [go-nuts] gob non-optimal serialization in case of interface

2021-04-04 Thread Robert Engels
Since Dimension can hold any instance type it needs to encode each type for each element of the slice. I would file an enhancement to use RLE when encoding interface slices. It won’t be backwards compatible though. > On Apr 4, 2021, at 10:22 AM, 'Axel Wagner' via golang-nuts > wrote: > >  >

Re: [go-nuts] gob non-optimal serialization in case of interface

2021-04-04 Thread 'Axel Wagner' via golang-nuts
Oh, I should also not, to be fair: You *can* decode the gob into an `[]Dimension`, but you *can't* do the same with json. So, the comparison with json is unfair insofar, as the encoded json is actually incomplete - it doesn't hold the type-information of *which* `Dimension` implementation to use.

Re: [go-nuts] gob non-optimal serialization in case of interface

2021-04-04 Thread 'Axel Wagner' via golang-nuts
I believe it is expected behavior (well… given that the gob format is pretty much defined as "whatever the gob package does", it surely is, at this point). gob is able to decode types completely, without having a "framework" to work on - you need to pass a pointer to `json.Unmarshal`, so that the d

[go-nuts] gob non-optimal serialization in case of interface

2021-04-04 Thread dev.nul...@gmail.com
Hi, Gob in general is pretty efficient however I am seeing, what seems to be an anomaly in its behavior when it comes to serilazing interfaces. To elaborate, I have a program defining a simple interface called Dimension and a struct Point. *type Dimension interface{}* *type Point struct {* * X,