{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "reference:global_state",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "NumPy has a few import-time, compile-time, or runtime configuration options which change the global behaviour.  Most of these are related to performance or for debugging purposes and will not be interesting to the vast majority of users."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Global Configuration Options"
        }
      ],
      "level": 0,
      "target": "global_state"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Performance-related options"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "NumPy itself is normally intentionally limited to a single thread during function calls, however it does support multiple Python threads running at the same time. Note that for performant linear algebra NumPy uses a BLAS backend such as OpenBLAS or MKL, which may use multiple threads that may be controlled by environment variables such as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "OMP_NUM_THREADS"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " depending on what is used. One way to control the number of threads is the package "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "threadpoolctl"
                }
              ],
              "url": "https://pypi.org/project/threadpoolctl/",
              "title": ""
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Number of threads used for linear algebra"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When working with very large arrays on modern Linux kernels, you can experience a significant speedup when "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "transparent hugepage"
                }
              ],
              "url": "https://www.kernel.org/doc/html/latest/admin-guide/mm/transhuge.html",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is used. The current system policy for transparent hugepages can be seen by      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "cat /sys/kernel/mm/transparent_hugepage/enabled",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When set to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "madvise"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " NumPy will typically use hugepages for a performance boost. This behaviour can be modified by setting the environment variable      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "NUMPY_MADVISE_HUGEPAGE=0",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "or setting it to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to always enable it. When not set, the default is to use madvise on Kernels 4.6 and newer. These kernels presumably experience a large speedup with hugepage support. This flag is checked at import time."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "madvise hugepage on Linux"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Setting "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "NPY_DISABLE_CPU_FEATURES"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will exclude simd features at runtime. See "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "runtime-simd-dispatch",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "reference:simd:build-options"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "SIMD feature selection"
        }
      ],
      "level": 2,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Debugging-related options"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Some users might pass ownership of the data pointer to the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " by setting the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "OWNDATA"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " flag. If they do this without setting (manually) a memory allocation policy, the default will be to call "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "free"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". If "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "NUMPY_WARN_IF_NO_MEM_POLICY"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is set to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "\"1\""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "RuntimeWarning"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will be emitted. A better alternative is to use a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "PyCapsule"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with a deallocator and set the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ndarray.base"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionchanged",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionchanged 1.25.2"
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "This variable is only checked on the first import."
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Warn if no memory allocation policy when deallocating data"
        }
      ],
      "level": 2,
      "target": null
    }
  ],
  "local_refs": []
}