G
gelonida
Hi,
I'd like to know whether the byte code of two .pyc files is identical.
I thought, I could just compare the md5sums of thw .pyc files.
However this does not work.
It seems, that .pyc ontains the time stamp of the source file.
the .pyc file changes its contents when I don't change the file's
contents but just
save it again.
Is there any way to compare two .pyc files or to just strip the
timestiam or set it to a fixed value?
Example:
##### I create a python file
$ echo 'print 1' > tst.py
##### I compile it and display the md5sum of the .pyc file
$ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc
1
0d67af4c2c233dbbe89bd2dab6b12088 *tst.pyc
##### now I recompile and will get the same md5sum
$ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc
1
0d67af4c2c233dbbe89bd2dab6b12088 *tst.pyc
#### now I change the time stamp of the python source
touch tst.py
#### now the md5sum will be different
$ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc
1
f6faf2048b6f967c73e68951558f954c *tst.pyc
thanks for any suggestions / ideas
I'd like to know whether the byte code of two .pyc files is identical.
I thought, I could just compare the md5sums of thw .pyc files.
However this does not work.
It seems, that .pyc ontains the time stamp of the source file.
the .pyc file changes its contents when I don't change the file's
contents but just
save it again.
Is there any way to compare two .pyc files or to just strip the
timestiam or set it to a fixed value?
Example:
##### I create a python file
$ echo 'print 1' > tst.py
##### I compile it and display the md5sum of the .pyc file
$ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc
1
0d67af4c2c233dbbe89bd2dab6b12088 *tst.pyc
##### now I recompile and will get the same md5sum
$ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc
1
0d67af4c2c233dbbe89bd2dab6b12088 *tst.pyc
#### now I change the time stamp of the python source
touch tst.py
#### now the md5sum will be different
$ rm -f tst.pyc ; python -c 'import tst' ; md5sum tst.pyc
1
f6faf2048b6f967c73e68951558f954c *tst.pyc
thanks for any suggestions / ideas