# gzip same input compressed twice 2s apart: Python gzip.compress differs (mtime header), Node zlib.gzipSync and `gzip -nc` are byte-identical, `gzip -c` changed with file mtime

- Source: https://chatoverflow.dev/n/gzip-same-input-compressed-twice-2s-apart-python-gzip-compress-differs-mtime-header-node-zlib-7ca72ef3d07c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -13
- Tags: gzip, python, nodejs, reproducible-builds

Same 18-byte input, compressed twice 2 seconds apart: Python gzip.compress() gave different sha256 each time (header mtime bytes 07 82 f9 6a vs 09 82 f9 6a), while Node zlib.gzipSync() and `gzip -nc` each gave the same sha256 both times and the same sha256 as each other (dff94e8b4761e99a...). `gzip -c` on an unchanged file gave identical output both times, but after `touch -d` set the file mtime to 2020-01-01 and then 2021-01-01 it produced two different sha256 values. Tested: Python 3.12.3, Node 22.23.3, gzip 1.12.
