Open
Description
The results of savez()
depend on the current time, because the underlying implementation uses tempdir
to cache result about to be written. From there the internal instance of ZipFile()
auto-detects the time/date and encodes them into the zipfile headers somewhere.
Here is a simple demo:
In [1]: import numpy as np
In [2]: import io
In [3]: bio1 = io.BytesIO()
In<
7C20
/span> [4]: bio2 = io.BytesIO()
In [5]: np.savez_compressed(bio1, foo="bar")
In [6]: import time
In [7]: time.sleep(1)
In [8]: np.savez_compressed(bio2, foo="bar")
In [9]: bio1.getvalue()
Out[9]: b'PK\x03\x04\x14\x00\x00\x00\x08\x00\x84s\xf2J\xd6i\x8cTK\x00\x00\x00\\\x00\x00\x00\x07\x00\x00\x00foo.npy\x9b\xec\x17\xea\x1b\x10\xc9\xc8\xe0\xc6P\xad\x9e\x92Z\x9c\\\xa4n\xa5\xa0n\x13j\xac\xae\xa3\xa0\x9e\x96_TR\x94\x98\x17\x9f_\x94\x92\n\x12wK\xcc)N\x05\x8a\x17g$\x16\xa4\x02\xf9\x1a\x9a:\n\xb5\n(\x80+\x89\x81\x81!\x11\x88\x8b\x80\x18\x00PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\x84s\xf2J\xd6i\x8cTK\x00\x00\x00\\\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x81\x00\x00\x00\x00foo.npyPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x005\x00\x00\x00p\x00\x00\x00\x00\x00'
^ HERE
In [10]: bio2.getvalue()
Out[10]: b'PK\x03\x04\x14\x00\x00\x00\x08\x00\x8cs\xf2J\xd6i\x8cTK\x00\x00\x00\\\x00\x00\x00\x07\x00\x00\x00foo.npy\x9b\xec\x17\xea\x1b\x10\xc9\xc8\xe0\xc6P\xad\x9e\x92Z\x9c\\\xa4n\xa5\xa0n\x13j\xac\xae\xa3\xa0\x9e\x96_TR\x94\x98\x17\x9f_\x94\x92\n\x12wK\xcc)N\x05\x8a\x17g$\x16\xa4\x02\xf9\x1a\x9a:\n\xb5\n(\x80+\x89\x81\x81!\x11\x88\x8b\x80\x18\x00PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\x8cs\xf2J\xd6i\x8cTK\x00\x00\x00\\\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x81\x00\x00\x00\x00foo.npyPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x005\x00\x00\x00p\x00\x00\x00\x00\x00'
^ HERE
In [11]: bio1.getvalue() == bio2.getvalue()
Out[11]: False
A minimum of 1 second difference is necessary for byte-wise similarity to fail.