Skip to main content

SSE flags

NumPy for x86 platforms (IA-32 and AMD64 architectures) uses SSE and/or AVX for floating-point calculations. Unfortunately, on Intel CPUs, they work very slowly with subnormal (denormal) numbers. To avoid such performance degradation, if somewhat worse floating-point accuracy in extreme cases can be tolerated, the DAZ (denormals-are-zero) and FTZ (flush-to-zero) CPU flags were introduced to treat input and/or output subnormal numbers as zeros. This module provides access to these CPU flags from Python.

To test the effect on your system, use sseflags.benchmark.run() or run

    python3 -m sseflags.benchmark

in the command line. Example output on Intel i9-12900K (subnormal numbers are very slow):

    Times in milliseconds:
    normal     0.037
    default    1.979
    ========================
             FTZ off  FTZ on
    ------------------------
    DAZ off    1.993   2.037
    DAZ on     6.669   0.037
    ========================

AMD CPUs do not show performance degradation on subnormal numbers in the 64-bit mode, and thus enabling DAZ/FTZ can only decrease the accuracy slightly. Example benchmarks on AMD Ryzen 7 6800U (negligible degradation for subnormal numbers; notice that times are in microseconds):

    Times in microseconds:
    normal    14.434
    default   16.834
    ========================
             FTZ off  FTZ on
    ------------------------
    DAZ off   16.829  15.383
    DAZ on    15.353  14.500
    ========================

Nevertheless, DAZ/FTZ might be useful in 32-bit Python (same CPU, noticeable difference):

    Times in milliseconds:
    normal     0.132
    default    0.229
    ========================
             FTZ off  FTZ on
    ------------------------
    DAZ off    0.225   0.131
    DAZ on     0.224   0.131
    ========================

AArch64 (ARM64) has the FZ flag to treat subnormal numbers as zeros similarly to both DAZ and FTZ together. Therefore, enabling it with the same interface is implemented here for compatibility. ARM CPUs with the FEAT_AFP feature (for example, Apple M3 but not M1) also support “alternate floating-point behavior” providing control equivalent to separate DAZ and FTZ flags; however, this is not implemented yet (mostly due to the lack of testing).

On other architectures, or if the underlying Cython extension is not built, the module only reports that it has no effect.

sseflags module

type Flags = {'daz': bool | None, 'ftz': bool | None}


get_flags() -> sseflags.Flags
    Query current states of the DAZ and FTZ flags, see set_flags() for details.
    Can be used for restoring the default behavior:

        flags = get_flags()            # remember the original flag states
        set_flags(daz=True, ftz=True)  # enable DAZ and FTZ
        ...                            # do some calculations
        set_flags(**flags)             # restore the original flag states

    Returns
    -------
    flags : dict
        dictionary with the keys 'daz' and 'ftz', values of which represent the
        corresponding flag state: True for set, False for cleared, None if not
        implemented


set_flags(
    daz: bool | None = None,
    ftz: bool | None = None,
    verbose: bool = False
) -> bool
    Set the DAZ (denormals-are-zero) and/or FTZ (flush-to-zero) CPU flags for
    SSE and AVX floating-point calculations, which can be useful for Intel CPUs
    that work very slowly with subnormal (denormal) numbers.

    On AArch64 (ARM64) CPUs, both DAZ and FTZ are represented by the FZ flag,
    thus the daz and ftz parameters must be equal.

    On unsupported architectures, or if the underlying Cython extension was not
    built, this function only reports that it has no effect. The availability
    can be checked by calling set_flags() without arguments.

    Parameters
    ----------
    daz : bool or None, optional
        True to set, False to clear the DAZ flag; None (default) to leave
        unchanged

    ftz : bool or None, optional
        True to set, False to clear the FTZ flag; None (default) to leave
        unchanged

    verbose : bool, optional
        pass True to print a warning if the operation is not implemented

    Returns
    -------
    implemented : bool
        True if this operation is implemented and supported, False if not

sseflags.benchmark submodule

run(repeat: int = 100, min_t: float = 1.0, verbose: bool = True) -> None
    Run benchmarks with all possible combinations of the DAZ and FTZ flags to
    check their effect on NumPy performance (see run_flags() for details).

    Parameters
    ----------
    repeat : int, optional
        number of iterations in a batch

    min_t : float, optional
        minimal amount of time in seconds to benchmark each combination

    verbose : bool, optional
        pass False to suppress the progress report


run_flags(
    flags: Union[sseflags.Flags, Literal['default', 'normal']],
    repeat: int = 100,
    min_t: float = 1.0
) -> float | None
    Set the DAZ and FTZ flags to given states and run a benchmark of NumPy
    matrix multiplication. Each iteration involves multiplication of normal
    numbers that would produce subnormal numbers and multiplication of
    subnormal numbers by normal numbers, which also would produce subnormal
    numbers.

    The test is designed for clear demonstration of performance degradation (if
    it is present); the effect for real-world data is usually less severe.

    Parameters
    ----------
    flags : dict or str
        dictionary with arguments passed to sseflags.set_flags() after creating
        subnormal test data;

        flags='default' benchmark without changing the flags (thus test data
        might be missing subnormal numbers, which corresponds to running
        self-contained calculations but does not represent calculations with
        external data);

        flags='normal' benchmark normal numbers for reference (should not
        depend on the flags)

    repeat : int, optional
        number of iterations in a batch

    min_t : float, optional
        batches are repeated until this amount of seconds passes

    Returns
    -------
    time : float or None
        average time per iteration in seconds; None if the flags cannot be set

sseflags.test submodule

run() -> None
    Basic tests to check the DAZ and FTZ flags and their effect on operations
    involving subnormal numbers.

    n is the smallest normal number, s = n / 2 is a subnormal number;
    the operation s * 2 should produce a normal number (or zero with DAZ),
    the operation n / 2 should produce a subnormal number (or zero with FTZ).

Installation

Compiled wheels for Linux, macOS and Windows can be installed from PyPI. They use “Stable ABI” that should be compatible with all Python versions ⩾3.10. For portability, a “universal wheel” is also available, which does not contain the Cython extension, and thus has no effect on computations, but can be installed on unsupported systems. It can still benchmark the performance difference between subnormal and normal numbers.

Metadata

Release files for sseflags 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sseflags 0.3
File Size Uploaded
sseflags-0.3.tar.gz 10.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for sseflags 0.3
File
sseflags-0.3-py3-none-any.whl Python 3 none any Details
sseflags-0.3-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
sseflags-0.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
sseflags-0.3-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details
sseflags-0.3-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
sseflags-0.3-cp310-abi3-musllinux_1_2_i686.whl CPython 3.10 abi3 Linux musl 1.2+ x86-32 Details
sseflags-0.3-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
sseflags-0.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
sseflags-0.3-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
sseflags-0.3-cp310-abi3-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-32, Linux glibc 2.5+ x86-32 Details
sseflags-0.3-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
sseflags-0.3-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details

Total release size: 220.4 kB

Release files / sseflags-0.3.tar.gz

Download URL sseflags-0.3.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0ea50a736ffa3853918eef7a58f2ec07dbe35346308a8101d3a16951bfd570e2
BLAKE2b-256 checksum
How to use checksums
537e998406a28bec2a6b73d5fff882c0e89b90938a83dc62aa99cc8f8c1093f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-py3-none-any.whl

Download URL sseflags-0.3-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
456c312c15b25038411eac939709dbcb68dc12682cb9ccdc771dec6e6306de7b
BLAKE2b-256 checksum
How to use checksums
30ebf5e6f61782deb3850cc54e5576a39708fd286817795d88561a44ce0a9e81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-win_arm64.whl

Download URL sseflags-0.3-cp310-abi3-win_arm64.whl
Size 17.7 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
40bb63a1d309c102dd363543ed0dd9b6b028602b6fc056d5835b2144a1c45aec
BLAKE2b-256 checksum
How to use checksums
93e56c1985b40ab2700b0c58d01dfcd42b8e6bf9775e965d8dc68b8b4e453707
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-win_amd64.whl

Download URL sseflags-0.3-cp310-abi3-win_amd64.whl
Size 19.1 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
437d7d5ac22774a0bcd0e29369cf0d19a067b17dcb7cc2705c12daad71f85bb1
BLAKE2b-256 checksum
How to use checksums
6263e7439e3af4a93704826982566dc2b54e65c332a3426b20ca0621e8886f69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-win32.whl

Download URL sseflags-0.3-cp310-abi3-win32.whl
Size 18.3 kB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
d99ea4f61f39deeaaeb9ed331146d658a0cb21f85c63bc55f700003b5bb00be2
BLAKE2b-256 checksum
How to use checksums
746dd99802076ebe9f4942d723cb1ef05e8b42452235b931345f085455dec800
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL sseflags-0.3-cp310-abi3-musllinux_1_2_x86_64.whl
Size 18.4 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
a9b29343b985ded3f588c55d76b1d5c3680e475e447b99c36f9d581ca84cf6b8
BLAKE2b-256 checksum
How to use checksums
df263ff0cff3a8365e2e62098a85a4452c60d585195484ee5a2901fd99e1edfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-musllinux_1_2_i686.whl

Download URL sseflags-0.3-cp310-abi3-musllinux_1_2_i686.whl
Size 18.6 kB
Tags CPython 3.10 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
7da7ea79bbea18b397fd4b5c59b36eafff256e98230eefca3f1164d5c2d8be95
BLAKE2b-256 checksum
How to use checksums
49e1bfffda7e0b1474564ea1ed460cb7714f676b01b1737fcf71948a7f8146eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL sseflags-0.3-cp310-abi3-musllinux_1_2_aarch64.whl
Size 19.1 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
350d59fe8302f23042cc3c4abc3c09d7b7aa377e9e6a6b3ec616cadd878aa0c3
BLAKE2b-256 checksum
How to use checksums
1f55e06b313ea21a48d28dc793d908f155c17c97e5f69401abb84bb4865fd25b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL sseflags-0.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 19.2 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
5a91c231de60d7901cc4c838289e17e57b5203d1993d68719d31cab60dafb93e
BLAKE2b-256 checksum
How to use checksums
8b04b3674d297b59a9f94580d9660cf4abc0b5392f14c7772a4ac5b9b4832708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL sseflags-0.3-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 18.1 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
ef753981e1ba76b8e1f682df443117ea94b4cec9148869168528677b93bc5972
BLAKE2b-256 checksum
How to use checksums
a081035d7a1c41edbdf0cdb9dd5bd7ff539319cf2f51973ec73f1812ce6c050b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl

Download URL sseflags-0.3-cp310-abi3-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl
Size 17.9 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-32 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
d75ebc395c9bb4802cc3f8d3b4e4de173de193eacf03139d302f34e71b59e6f0
BLAKE2b-256 checksum
How to use checksums
0b8c0f7e3b43c2061500f464cddf2c2bded3fead922128acd82658fc98a066bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-macosx_11_0_arm64.whl

Download URL sseflags-0.3-cp310-abi3-macosx_11_0_arm64.whl
Size 17.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dbd56f3826bfe459eefb6c907c231644e84222c0ed9ca90a06b692de834d227c
BLAKE2b-256 checksum
How to use checksums
cfbde5ed3e39030f5a439c69c25d0afbc68edd5bd39ce763384ec84fc90c4f3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / sseflags-0.3-cp310-abi3-macosx_10_9_x86_64.whl

Download URL sseflags-0.3-cp310-abi3-macosx_10_9_x86_64.whl
Size 16.4 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
a225b0234e052b1917f82e758077eec5ea77434217cf9dd066ed79b67d2f8da1
BLAKE2b-256 checksum
How to use checksums
9996996313d298ce99bde1136452ffc67d0fdab21c7d780c7b269db09b0386ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3 This release

13 release files

0.2

9 release files

0.1

9 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page