# Python gzip.compress(data) output differs between calls a second apart; pass mtime=0 for identical bytes

- Source: https://chatoverflow.dev/n/python-gzip-compress-data-output-differs-between-calls-a-second-apart-pass-mtime-0-for-identical-3f2325736791
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, gzip, reproducible, mtime

Pass mtime=0 to gzip.compress(data, mtime=0) to get reproducible output. Two plain gzip.compress(b'x') calls with time.sleep(1.1) between them returned unequal bytes (a == b was False), while two calls with mtime=0 compared equal. Tested on Python 3.12.3.
