You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6829 Reporter:@dbuenzli Assigned to:@alainfrisch Status: resolved (set by @alainfrisch on 2016-12-06T15:28:38Z) Resolution: fixed Priority: normal Severity: feature Version: 4.02.1 Fixed in version: 4.04.0 Category: standard library Monitored by:@diml@hcarty@dbuenzli
Bug description
It would be nice to have a function in the standard library that allows to get the size of an arbitrary value. This is useful when trying alternate encodings and/or data structures e.g. to minimise in-memory representations of a particular data set.
For now to get a quick estimation I sometimes simply marshal the value to a string, or resort to ad-hoc functions that perform the count on the datastructure at hand e.g.:
Any implementation will basically be a rewrite of the Marshal functions, so we probably should just modify the marshalling primitives to have an option to output only the size.
I think it would be cleaner to create a new function instead. The body of the marshal function, i.e. extern_rec in byterun/extern.c is quite small, and if we keep only the logic to count the size, it would be even smaller (e.g. we don't need to handle various cases for "small integers" or "short strings"; and one can merge cases String_tag/Double_tag/Double_array_tag/Custom_tag).
Original bug ID: 6829
Reporter: @dbuenzli
Assigned to: @alainfrisch
Status: resolved (set by @alainfrisch on 2016-12-06T15:28:38Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 4.02.1
Fixed in version: 4.04.0
Category: standard library
Monitored by: @diml @hcarty @dbuenzli
Bug description
It would be nice to have a function in the standard library that allows to get the size of an arbitrary value. This is useful when trying alternate encodings and/or data structures e.g. to minimise in-memory representations of a particular data set.
For now to get a quick estimation I sometimes simply marshal the value to a string, or resort to ad-hoc functions that perform the count on the datastructure at hand e.g.:
https://github.com/dbuenzli/uucp/blob/master/src/uucp_cmap.ml#L57-L63
https://github.com/dbuenzli/uucp/blob/master/src/uucp_rmap.ml#L60-L66
https://github.com/dbuenzli/uucp/blob/master/src/uucp_tmap.ml#L39-L56
https://github.com/dbuenzli/uucp/blob/master/src/uucp_tmapbool.ml#L53-L65
But could we maybe rather have something like Jean-Christophe Filliatre's size functions [1] directly in the Gc module ?
Thanks,
Daniel
[1] https://www.lri.fr/~filliatr/ftp/ocaml/ds/size.ml.html
The text was updated successfully, but these errors were encountered: