Adding binarySize to Binary
ekarttun at cs.helsinki.fi
Sun Feb 4 09:33:52 EST 2007
On 04.02 12:31, Duncan Coutts wrote:
> Dons wrote:
> > Yes, I've thought this would be useful too. A la 'sizeOf' in Storable.
> > Should it be a member of the Binary class?
Yes, as there is no other good way of implementing it in general.
> What would it mean? How hard would it have to work to be accurate? Is
> this just for (mostly-)fixed size records? What about lists? I don't
> think we should be forcing the list just to see how big it is.
As it would operate on types rather than values (think sizeOf), the
result for "[a]" would probably be "(1, Nothing)" - a list takes one
byte at minimum and infinite bytes at maximum.
> What is the use-case?
I am playing with on disk B-tree like things and object sizes become
quite important when deciding layout. Several optimizations can be
done if the objects are known to be fixed size (or have only small
size variations). And if it is known beforehand how many objects will
fit into a page that helps too.
More information about the Libraries