Darwin Help

Back to Index

compress

Function compress - compress an arbitrary object

Calling Sequence  compress(obj)
Parameters
NameTypeDescription

obj anythingobject to compress
Return Type  compressed
Synopsis Compress takes any structure and compresses it in a simple way. The function decompress restores the original expression. Normally this is used in cases that lots of structures are stored in main memory and this would require too much memory and the structures are not used often enough, so that it pays to decompress them before using them. There are several internal structures which are not compressed, most notably Dayhoff matrices and databases. Consequently, structures that reference these will (e.g. Alignment) will not be compressed. The compression factor is about 3:1 for general structures on a 32-bit word implementation, higher for 64-bit words.
Examples
> t := compress([1,2,{3,4}]);
t := [1, 2, {3,4}]
> decompress(t);
[1, 2, {3,4}]
> size(t)/size([1,2,{3,4}]);
0.2727


See also decompress,   length,   size,   system