Skip to content

Slow performance of compression.lzma and compression.bz2 #846

@robquant

Description

@robquant

While comparing Python version performance with https://github.com/lucianmarin/pybench I found that python-build-standalone versions show considerably slower compression/decompression performance than OS versions on Linux and macOS.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
Codename:       trixie
~/pybench$ /usr/bin/python3 -c "import sys;print(sys.version)"
3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0]
~/pybench$ /usr/bin/python3 bench.py
Compress using BZ2 algorithm:
[========================================] 100.0% 0:00:09
Compress using LZMA algorithm:
[========================================] 100.0% 0:00:08
[...]
~/pybench$ uv run --python 3.13.5 --managed-python python bench.py
Compress using BZ2 algorithm:
[========================================] 100.0% 0:00:27
Compress using LZMA algorithm:
[========================================] 100.0% 0:00:31
[...]

I believe the cause is the same as in #761.
The CFLAGS in build-bzip2.sh and build-xz.sh overwrite the CFLAGS in the respective upstream Makefile. When an -O2 is added to the CFLAGS in each build script, the performance of the python-build-standalone version in in line with the system Python!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions