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, Y, Z int64*
*}*
In first case I encode a slice of 10K Points but stored in an []Dimension 
and in the second case i do the same with 10K Points stored in an []Point. 
The former case serialized to disk is 526KB whereas later is only 146KB. 
The type Point is registered using gob.Register

My naive interpretation is that the type is getting encoded for every entry 
in the slice which seems non-optimal. I would hope that once the type 
description is encoded it would be referenced and it shouldn't result in 
this big difference.
Infact serializing to JSON also yields only 300KB.
 
The full sample code can be found here
https://play.golang.org/p/QLQm5BM25WW

Am I missing something here or is this the expected behavior?
Regards
Monmohan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6ececfc1-b21c-4177-acbf-4847c42486fdn%40googlegroups.com.

Reply via email to