{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Parameter specification variable."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The preferred way to construct a parameter specification is via the dedicated syntax for generic functions, classes, and type aliases, where the use of '**' creates a parameter specification      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "type IntFunc[**P] = Callable[P, int]",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The following syntax creates a parameter specification that defaults to a callable accepting two positional-only arguments of types int and str:"
            }
          ]
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "type IntFuncDefault[**P = [int, str]] = Callable[P, int]"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For compatibility with Python 3.11 and earlier, ParamSpec objects can also be created as follows      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "P = ParamSpec('P')\nDefaultP = ParamSpec('DefaultP', default=[int, str])",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Parameter specification variables exist primarily for the benefit of static type checkers.  They are used to forward the parameter types of one callable to another callable, a pattern commonly found in higher-order functions and decorators.  They are only valid when used in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "Concatenate"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", or as the first argument to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "Callable"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", or as parameters for user-defined Generics. See class Generic for more information on generic types."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "An example for annotating a decorator      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "def add_logging[**P, T](f: Callable[P, T]) -> Callable[P, T]:\n    '''A type-safe decorator to add logging to a function.'''\n    def inner(*args: P.args, **kwargs: P.kwargs) -> T:\n        logging.info(f'{f.__name__} was called')\n        return f(*args, **kwargs)\n    return inner\n\n@add_logging\ndef add_two(x: float, y: float) -> float:\n    '''Add two numbers together.'''\n    return x + y",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Parameter specification variables can be introspected. e.g.      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": ">>> P = ParamSpec(\"P\")\n>>> P.__name__\n'P'",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that only parameter specification variables defined in the global scope can be pickled."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/opt/hostedtoolcache/Python/3.14.5/x64/lib/python3.14/typing.py",
  "item_line": null,
  "item_type": "ParamSpec",
  "aliases": [
    "scipy.differentiate.xpx._lib._lazy.P"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "scipy._lib.array_api_extra._lib._lazy:P",
  "arbitrary": [],
  "local_refs": []
}