Why saving matc files with scipy results in a larger file size than Matlab?

Let's say I generate the following toy dataset from Matlab, and I save it as a mat file:

>> arr = rand(100);
>> whos arr
  Name        Size             Bytes  Class     Attributes

  arr       100x100            80000  double
>> save('arr.mat', 'arr')

The saved file arr.matis sized 75829 Bytesaccording to the output of the command ls.

If I download the same file with scipy.io.loadmat()and save it again using scipy.io.savemat():

arr = io.loadmat('arr.mat')
with open('arrscipy.mat', 'w') as f:
    io.savemat(f, arr)

I get a file with a significantly larger size (& sim; 4KB larger):

$ ls -al
75829 Nov  6 11:52 arr.mat
80184 Nov  6 11:52 arrscipy.mat

, . , , - . . ? ?

, : , scipy, , Matlab.

+4
2

docs:

scipy.io.savemat(file_name, mdict, appendmat=True, format='5',
    long_field_names=False, do_compression=False, oned_as='row')

. matlab .

+4

do_compression = True. MATLAB do_compression = True.

, 2 MATLAB (2017b), do_compression True False, 2.25 GB, scipy.io.savemat() , MATLAB , Python loadmat().

scipy.io.savemat format = '5', MATLAB 7.2. , . MATLAB save() "-v7.3" 2 . , , scipy savemat , , MATLAB 7.3 2 .

, scipy , .

0

Source: https://habr.com/ru/post/1614717/


All Articles