CINXE.COM

peps/peps/pep-0622.rst at main · python/peps · GitHub

<!DOCTYPE html> <html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system" data-a11y-link-underlines="true" > <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-74231a1f3bbb.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-8a995f0bacd4.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-f37fb7684b1f.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-9ac301c3ebe5.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-cd826e8636dc.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-f91b0f603451.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-83beb16e0ecf.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-6e122dab64fc.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-18119e682df0.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-primitives-225433424a87.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-aaa714e5674d.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0a3c53b9d1c2.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-ea73c9cb5377.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/repository-4fce88777fa8.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-0210be90f4d3.css" /> <script type="application/json" id="client-env">{"locale":"en","featureFlags":["a11y_quote_reply_fix","copilot_immersive_issue_preview","copilot_new_references_ui","copilot_chat_repo_custom_instructions_preview","copilot_no_floating_button","copilot_topics_as_references","copilot_read_shared_conversation","copilot_duplicate_thread","copilot_buffered_streaming","dotcom_chat_client_side_skills","experimentation_azure_variant_endpoint","failbot_handle_non_errors","geojson_azure_maps","ghost_pilot_confidence_truncation_25","ghost_pilot_confidence_truncation_40","github_models_gateway_parse_params","github_models_o3_mini_streaming","insert_before_patch","issues_react_remove_placeholders","issues_react_blur_item_picker_on_close","marketing_pages_search_explore_provider","primer_react_css_modules_ga","react_data_router_pull_requests","remove_child_patch","sample_network_conn_type","swp_enterprise_contact_form","site_proxima_australia_update","viewscreen_sandbox","issues_react_create_milestone","issues_react_cache_fix_workaround","lifecycle_label_name_updates","copilot_task_oriented_assistive_prompts","issue_types_prevent_private_type_creation","refresh_image_video_src","react_router_dispose_on_disconnect","codespaces_prebuild_region_target_update","turbo_app_id_restore","copilot_code_review_sign_up_closed"]}</script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-1ad576e595f5.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_oddbird_popover-polyfill_dist_popover_js-9da652f58479.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_arianotify-polyfill_ariaNotify-polyfill_js-node_modules_github_mi-3abb8f-46b9f4874d95.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_failbot_failbot_ts-75968cfb5298.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-f04cb2a9fc8c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_index_mjs-0dbb79f97f8f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-f690fd9ae3d5.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-62d275b7ddd9.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_text-expander-element_dist_index_js-78748950cb0c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-8e9f78-a90ac05d2469.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-b5f1d7-a1760ffda83d.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_markdown-toolbar-element_dist_index_js-ceef33f593fa.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_primer_view-co-c44a69-efa32db3a345.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-394f8eb34f19.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-25113a65b77f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_braintree_browser-detection_dist_browser-detection_js-node_modules_githu-2906d7-2a07a295af40.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-be8cb88f481b.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_morphdom_dist_morphdom-e-7c534c-a4a1922eb55f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_turbo_dist_turbo_es2017-esm_js-a03ee12d659a.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-893f9f-b6294cf703b7.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-e3180fe3bcb3.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_quote-selection_dist_index_js-node_modules_github_session-resume_-947061-e7a6c4a19f98.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_updatable-content_updatable-content_ts-eb3147a21e96.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_task-list_ts-app_assets_modules_github_sso_ts-ui_packages-900dde-768abe60b1f8.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-3e000c5d31a9.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_ajax-error_ts-app_assets_modules_github_behaviors_include-87a4ae-4c160a67a3f8.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-e429cff6ceb1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-1f167e0c2aee.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-f6223d90c7ba.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-01e85cd1be94.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_catalyst_lib_inde-dbbea9-26cce2010167.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-1c0aedc134b1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/primer-react-602097a4b0db.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/react-core-0bc17999cb79.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/react-lib-f1bca44e0926.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/octicons-react-cf2f2ab8dab4.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_emotion_is-prop-valid_dist_emotion-is-prop-valid_esm_js-node_modules_emo-62da9f-2df2f32ec596.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_stacktrace-parser_dist_s-e7dcdd-9a233856b02c.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_oddbird_popover-polyfill_dist_popover-fn_js-55fea94174bf.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_dompurify_dist_purify_es_mjs-dd1d3ea6a436.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lodash-es__Stack_js-node_modules_lodash-es__Uint8Array_js-node_modules_l-4faaa6-4a736fde5c2f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lodash-es__baseIsEqual_js-8929eb9718d5.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_react-intersection-observer_react-intersection-observer_modern_mjs-node_-b27033-ba82cef135e3.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_focus-visible_dist_focus-visible_js-node_modules_fzy_js_index_js-node_mo-f2fece-29a0ceccb1f1.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_aria-live_aria-live_ts-ui_packages_history_history_ts-ui_packages_promise-with-re-01dc80-134579ff449f.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_paths_index_ts-3adbcf6faa83.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_ref-selector_RefSelector_tsx-7496afc3784d.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_commit-attribution_index_ts-ui_packages_commit-checks-status_index_ts-ui_packages-7094d4-b869a469ca5e.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_diffs_diff-parts_ts-b05d9274ce63.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_app-uuid_app-uuid_ts-ui_packages_document-metadata_document-metadata_ts-ui_packag-4d8de9-e34d18d8cc94.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_hydro-analytics_hydro-analytics_ts-ui_packages_verified-fetch_verified-fetch_ts-u-4672d1-96a19eaeffb7.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_code-view-shared_hooks_use-canonical-object_ts-ui_packages_code-view-shared_hooks-d63960-3a5579c864b4.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_blob-anchor_ts-ui_packages_code-nav_code-nav_ts-ui_packages_filter--8253c1-91468a3354f9.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/react-code-view-45766ab73683.js"></script> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/react-code-view.91744b0963019bd58290.module.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-subscriptions-menu-57956eade845.js"></script> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/notifications-subscriptions-menu.1bcff9205c241e99cff2.module.css" /> <title>peps/peps/pep-0622.rst at main · python/peps · GitHub</title> <meta name="route-pattern" content="/:user_id/:repository/blob/*name(/*path)" data-turbo-transient> <meta name="route-controller" content="blob" data-turbo-transient> <meta name="route-action" content="show" data-turbo-transient> <meta name="current-catalog-service-hash" content="f3abb0cc802f3d7b95fc8762b94bdcb13bf39634c40c357301c4aa1d67a256fb"> <meta name="request-id" content="D8F2:193023:8D0C84:AFD27A:67E80CC2" data-pjax-transient="true"/><meta name="html-safe-nonce" content="2e652ce2600a974b01d214a0994038526ac74c2345bda0c0103d66930001aebe" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOEYyOjE5MzAyMzo4RDBDODQ6QUZEMjdBOjY3RTgwQ0MyIiwidmlzaXRvcl9pZCI6IjE0MDg1MDczNTY1MDMzNDYzNzAiLCJyZWdpb25fZWRnZSI6InNvdXRoZWFzdGFzaWEiLCJyZWdpb25fcmVuZGVyIjoic291dGhlYXN0YXNpYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="2a13de70824bf53d84462fffab1f53021fb1d540735b65cb2685011a981eba8b" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:13414105" data-turbo-transient> <meta name="github-keyboard-shortcuts" content="repository,source-code,file-tree,copilot" data-turbo-transient="true" /> <meta name="selected-link" value="repo_source" data-turbo-transient> <link rel="assets" href="https://github.githubassets.com/"> <meta name="google-site-verification" content="Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I"> <meta name="octolytics-url" content="https://collector.github.com/github/collect" /> <meta name="analytics-location" content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-turbo-transient="true" /> <meta name="user-login" content=""> <meta name="viewport" content="width=device-width"> <meta name="description" content="Python Enhancement Proposals. Contribute to python/peps development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905, app-argument=https://github.com/python/peps/blob/main/peps/pep-0622.rst" /> <meta name="twitter:image" content="https://opengraph.githubassets.com/d798d454e71d15ffaad6fb88a31524153c6df66cc6fd7f8e6f70ca5c5364f339/python/peps" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="peps/peps/pep-0622.rst at main · python/peps" /><meta name="twitter:description" content="Python Enhancement Proposals. Contribute to python/peps development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/d798d454e71d15ffaad6fb88a31524153c6df66cc6fd7f8e6f70ca5c5364f339/python/peps" /><meta property="og:image:alt" content="Python Enhancement Proposals. Contribute to python/peps development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="peps/peps/pep-0622.rst at main · python/peps" /><meta property="og:url" content="https://github.com/python/peps/blob/main/peps/pep-0622.rst" /><meta property="og:description" content="Python Enhancement Proposals. Contribute to python/peps development by creating an account on GitHub." /> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta http-equiv="x-pjax-version" content="de97acdfed47f9fb61814ae236bb7343666df83e298b7bdbb2f7cc7574846211" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="e26f9f0ba624ee85cc7ac057d8faa8618a4f25a85eab052c33d018ac0f6b1a46" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="159e03504eed5183f9787c72780a7d8c1460af30746ab09d728b048c41719efa" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="f2d91a2ff8587586cba3d4cfc1be461406926757eaf5ec500d81977d36511c4f" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta name="turbo-cache-control" content="no-cache" data-turbo-transient> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/python/peps git https://github.com/python/peps.git"> <meta name="octolytics-dimension-user_id" content="1525981" /><meta name="octolytics-dimension-user_login" content="python" /><meta name="octolytics-dimension-repository_id" content="13414105" /><meta name="octolytics-dimension-repository_nwo" content="python/peps" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="13414105" /><meta name="octolytics-dimension-repository_network_root_nwo" content="python/peps" /> <meta name="turbo-body-classes" content="logged-out env-production page-responsive"> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <meta name="release" content="9cd71f08d9519884edc4f4181a26ffafaf54bfbe"> <link rel="mask-icon" href="https://github.githubassets.com/assets/pinned-octocat-093da3e6fa40.svg" color="#000000"> <link rel="alternate icon" class="js-site-favicon" type="image/png" href="https://github.githubassets.com/favicons/favicon.png"> <link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg" data-base-href="https://github.githubassets.com/favicons/favicon"> <meta name="theme-color" content="#1e2327"> <meta name="color-scheme" content="light dark" /> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div data-turbo-body class="logged-out env-production page-responsive" style="word-wrap: break-word;"> <div class="position-relative header-wrapper js-header-wrapper "> <a href="#start-of-content" data-skip-target-assigned="false" class="px-2 py-4 color-bg-accent-emphasis color-fg-on-emphasis show-on-focus js-skip-to-content">Skip to content</a> <span data-view-component="true" class="progress-pjax-loader Progress position-fixed width-full"> <span style="width: 0%;" data-view-component="true" class="Progress-item progress-pjax-loader-bar left-0 top-0 color-bg-accent-emphasis"></span> </span> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_ui-commands_ui-commands_ts-2ea4e93613c0.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/keyboard-shortcuts-dialog-79d6a754ebf9.js"></script> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react.8157a56b30ae88a1b356.module.css" /> <react-partial partial-name="keyboard-shortcuts-dialog" data-ssr="false" data-attempted-ssr="false" > <script type="application/json" data-target="react-partial.embeddedData">{"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}</script> <div data-target="react-partial.reactRoot"></div> </react-partial> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-94fd67-4898d1bf4b51.js"></script> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-730dca81d0a2.js"></script> <header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark> <h2 class="sr-only">Navigation Menu</h2> <button type="button" class="HeaderMktg-backdrop d-lg-none border-0 position-fixed top-0 left-0 width-full height-full js-details-target" aria-label="Toggle navigation"> <span class="d-none">Toggle navigation</span> </button> <div class="d-flex flex-column flex-lg-row flex-items-center px-3 px-md-4 px-lg-5 height-full position-relative z-1"> <div class="d-flex flex-justify-between flex-items-center width-full width-lg-auto"> <div class="flex-1"> <button aria-label="Toggle navigation" aria-expanded="false" type="button" data-view-component="true" class="js-details-target js-nav-padding-recalculate js-header-menu-toggle Button--link Button--medium Button d-lg-none color-fg-inherit p-1"> <span class="Button-content"> <span class="Button-label"><div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div> <div class="HeaderMenu-toggle-bar rounded my-1"></div></span> </span> </button> </div> <a class="mr-lg-3 color-fg-inherit flex-order-2 js-prevent-focus-on-mobile-nav" href="/" aria-label="Homepage" data-analytics-event="{&quot;category&quot;:&quot;Marketing nav&quot;,&quot;action&quot;:&quot;click to go to homepage&quot;,&quot;label&quot;:&quot;ref_page:Marketing;ref_cta:Logomark;ref_loc:Header&quot;}"> <svg height="32" aria-hidden="true" viewBox="0 0 24 24" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github"> <path d="M12 1C5.9225 1 1 5.9225 1 12C1 16.8675 4.14875 20.9787 8.52125 22.4362C9.07125 22.5325 9.2775 22.2025 9.2775 21.9137C9.2775 21.6525 9.26375 20.7862 9.26375 19.865C6.5 20.3737 5.785 19.1912 5.565 18.5725C5.44125 18.2562 4.905 17.28 4.4375 17.0187C4.0525 16.8125 3.5025 16.3037 4.42375 16.29C5.29 16.2762 5.90875 17.0875 6.115 17.4175C7.105 19.0812 8.68625 18.6137 9.31875 18.325C9.415 17.61 9.70375 17.1287 10.02 16.8537C7.5725 16.5787 5.015 15.63 5.015 11.4225C5.015 10.2262 5.44125 9.23625 6.1425 8.46625C6.0325 8.19125 5.6475 7.06375 6.2525 5.55125C6.2525 5.55125 7.17375 5.2625 9.2775 6.67875C10.1575 6.43125 11.0925 6.3075 12.0275 6.3075C12.9625 6.3075 13.8975 6.43125 14.7775 6.67875C16.8813 5.24875 17.8025 5.55125 17.8025 5.55125C18.4075 7.06375 18.0225 8.19125 17.9125 8.46625C18.6138 9.23625 19.04 10.2125 19.04 11.4225C19.04 15.6437 16.4688 16.5787 14.0213 16.8537C14.42 17.1975 14.7638 17.8575 14.7638 18.8887C14.7638 20.36 14.75 21.5425 14.75 21.9137C14.75 22.2025 14.9563 22.5462 15.5063 22.4362C19.8513 20.9787 23 16.8537 23 12C23 5.9225 18.0775 1 12 1Z"></path> </svg> </a> <div class="flex-1 flex-order-2 text-right"> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fpeps%2Fblob%2Fmain%2Fpeps%2Fpep-0622.rst" class="HeaderMenu-link HeaderMenu-button d-inline-flex d-lg-none flex-order-1 f5 no-underline border color-border-default rounded-2 px-2 py-1 color-fg-inherit js-prevent-focus-on-mobile-nav" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/python/peps/blob/main/peps/pep-0622.rst&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="e07bcba36c1f06f8020123a139fd0d9e546d47cd71466ea4fb3f4492328c426c" data-analytics-event="{&quot;category&quot;:&quot;Marketing nav&quot;,&quot;action&quot;:&quot;click to Sign in&quot;,&quot;label&quot;:&quot;ref_page:Marketing;ref_cta:Sign in;ref_loc:Header&quot;}" > Sign in </a> </div> </div> <div class="HeaderMenu js-header-menu height-fit position-lg-relative d-lg-flex flex-column flex-auto top-0"> <div class="HeaderMenu-wrapper d-flex flex-column flex-self-start flex-lg-row flex-auto rounded rounded-lg-0"> <nav class="HeaderMenu-nav" aria-label="Global"> <ul class="d-lg-flex list-style-none"> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Product <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 d-lg-flex flex-wrap dropdown-menu-wide"> <div class="HeaderMenu-column px-lg-4 border-lg-right mb-4 mb-lg-0 pr-lg-7"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;github_copilot&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;github_copilot_link_product_navbar&quot;}" href="https://github.com/features/copilot"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M23.922 16.992c-.861 1.495-5.859 5.023-11.922 5.023-6.063 0-11.061-3.528-11.922-5.023A.641.641 0 0 1 0 16.736v-2.869a.841.841 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952 1.399-1.136 3.392-2.093 6.122-2.093 2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.832.832 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256ZM12.172 11h-.344a4.323 4.323 0 0 1-.355.508C10.703 12.455 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a2.005 2.005 0 0 1-.085-.104L4 11.741v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.016.016Zm.641-2.935c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z"></path><path d="M14.5 14.25a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Zm-5 0a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Z"></path> </svg> <div> <div class="color-fg-default h4">GitHub Copilot</div> Write better code with AI </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;security&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;security_link_product_navbar&quot;}" href="https://github.com/features/security"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path> </svg> <div> <div class="color-fg-default h4">Security</div> Find and fix vulnerabilities </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;actions&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;actions_link_product_navbar&quot;}" href="https://github.com/features/actions"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-workflow color-fg-subtle mr-3"> <path d="M1 3a2 2 0 0 1 2-2h6.5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2H7v4.063C7 16.355 7.644 17 8.438 17H12.5v-2.5a2 2 0 0 1 2-2H21a2 2 0 0 1 2 2V21a2 2 0 0 1-2 2h-6.5a2 2 0 0 1-2-2v-2.5H8.437A2.939 2.939 0 0 1 5.5 15.562V11.5H3a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v6.5a.5.5 0 0 0 .5.5h6.5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5ZM14.5 14a.5.5 0 0 0-.5.5V21a.5.5 0 0 0 .5.5H21a.5.5 0 0 0 .5-.5v-6.5a.5.5 0 0 0-.5-.5Z"></path> </svg> <div> <div class="color-fg-default h4">Actions</div> Automate any workflow </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;codespaces&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;codespaces_link_product_navbar&quot;}" href="https://github.com/features/codespaces"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-codespaces color-fg-subtle mr-3"> <path d="M3.5 3.75C3.5 2.784 4.284 2 5.25 2h13.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 18.75 13H5.25a1.75 1.75 0 0 1-1.75-1.75Zm-2 12c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v4a1.75 1.75 0 0 1-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75ZM5.25 3.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h13.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Zm-2 12a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h17.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25Z"></path><path d="M10 17.75a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path> </svg> <div> <div class="color-fg-default h4">Codespaces</div> Instant dev environments </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;issues&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;issues_link_product_navbar&quot;}" href="https://github.com/features/issues"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-issue-opened color-fg-subtle mr-3"> <path d="M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Zm9.5 2a2 2 0 1 1-.001-3.999A2 2 0 0 1 12 14Z"></path> </svg> <div> <div class="color-fg-default h4">Issues</div> Plan and track work </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;code_review&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;code_review_link_product_navbar&quot;}" href="https://github.com/features/code-review"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-review color-fg-subtle mr-3"> <path d="M10.3 6.74a.75.75 0 0 1-.04 1.06l-2.908 2.7 2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M1.5 4.25c0-.966.784-1.75 1.75-1.75h17.5c.966 0 1.75.784 1.75 1.75v12.5a1.75 1.75 0 0 1-1.75 1.75h-9.69l-3.573 3.573A1.458 1.458 0 0 1 5 21.043V18.5H3.25a1.75 1.75 0 0 1-1.75-1.75ZM3.25 4a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h2.5a.75.75 0 0 1 .75.75v3.19l3.72-3.72a.749.749 0 0 1 .53-.22h10a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25Z"></path> </svg> <div> <div class="color-fg-default h4">Code Review</div> Manage code changes </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;discussions&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;discussions_link_product_navbar&quot;}" href="https://github.com/features/discussions"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path> </svg> <div> <div class="color-fg-default h4">Discussions</div> Collaborate outside of code </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;code_search&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;code_search_link_product_navbar&quot;}" href="https://github.com/features/code-search"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-code-square color-fg-subtle mr-3"> <path d="M10.3 8.24a.75.75 0 0 1-.04 1.06L7.352 12l2.908 2.7a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 0 1 1.06.04Zm3.44 1.06a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.908-2.7-2.908-2.7Z"></path><path d="M2 3.75C2 2.784 2.784 2 3.75 2h16.5c.966 0 1.75.784 1.75 1.75v16.5A1.75 1.75 0 0 1 20.25 22H3.75A1.75 1.75 0 0 1 2 20.25Zm1.75-.25a.25.25 0 0 0-.25.25v16.5c0 .138.112.25.25.25h16.5a.25.25 0 0 0 .25-.25V3.75a.25.25 0 0 0-.25-.25Z"></path> </svg> <div> <div class="color-fg-default h4">Code Search</div> Find more, search less </div> </a></li> </ul> </div> </div> <div class="HeaderMenu-column px-lg-4"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="product-explore-heading">Explore</span> <ul class="list-style-none f5" aria-labelledby="product-explore-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;all_features&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;all_features_link_product_navbar&quot;}" href="https://github.com/features"> All features </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;documentation&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;documentation_link_product_navbar&quot;}" href="https://docs.github.com"> Documentation <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;github_skills&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;github_skills_link_product_navbar&quot;}" href="https://skills.github.com"> GitHub Skills <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;blog&quot;,&quot;context&quot;:&quot;product&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;blog_link_product_navbar&quot;}" href="https://github.blog"> Blog <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Solutions <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 d-lg-flex flex-wrap dropdown-menu-wide"> <div class="HeaderMenu-column px-lg-4 border-lg-right mb-4 mb-lg-0 pr-lg-7"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0 pb-lg-3 mb-3 mb-lg-0"> <span class="d-block h4 color-fg-default my-1" id="solutions-by-company-size-heading">By company size</span> <ul class="list-style-none f5" aria-labelledby="solutions-by-company-size-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;enterprises&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;enterprises_link_solutions_navbar&quot;}" href="https://github.com/enterprise"> Enterprises </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;small_and_medium_teams&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;small_and_medium_teams_link_solutions_navbar&quot;}" href="https://github.com/team"> Small and medium teams </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;startups&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;startups_link_solutions_navbar&quot;}" href="https://github.com/enterprise/startups"> Startups </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;nonprofits&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;nonprofits_link_solutions_navbar&quot;}" href="/solutions/industry/nonprofits"> Nonprofits </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="solutions-by-use-case-heading">By use case</span> <ul class="list-style-none f5" aria-labelledby="solutions-by-use-case-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;devsecops&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;devsecops_link_solutions_navbar&quot;}" href="/solutions/use-case/devsecops"> DevSecOps </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;devops&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;devops_link_solutions_navbar&quot;}" href="/solutions/use-case/devops"> DevOps </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;ci_cd&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;ci_cd_link_solutions_navbar&quot;}" href="/solutions/use-case/ci-cd"> CI/CD </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;view_all_use_cases&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;view_all_use_cases_link_solutions_navbar&quot;}" href="/solutions/use-case"> View all use cases </a></li> </ul> </div> </div> <div class="HeaderMenu-column px-lg-4"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="solutions-by-industry-heading">By industry</span> <ul class="list-style-none f5" aria-labelledby="solutions-by-industry-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;healthcare&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;healthcare_link_solutions_navbar&quot;}" href="/solutions/industry/healthcare"> Healthcare </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;financial_services&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;financial_services_link_solutions_navbar&quot;}" href="/solutions/industry/financial-services"> Financial services </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;manufacturing&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;manufacturing_link_solutions_navbar&quot;}" href="/solutions/industry/manufacturing"> Manufacturing </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;government&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;government_link_solutions_navbar&quot;}" href="/solutions/industry/government"> Government </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;view_all_industries&quot;,&quot;context&quot;:&quot;solutions&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;view_all_industries_link_solutions_navbar&quot;}" href="/solutions/industry"> View all industries </a></li> </ul> </div> </div> <div class="HeaderMenu-trailing-link rounded-bottom-2 flex-shrink-0 mt-lg-4 px-lg-4 py-4 py-lg-3 f5 text-semibold"> <a href="/solutions"> View all solutions <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-right HeaderMenu-trailing-link-icon"> <path d="M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"></path> </svg> </a> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Resources <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 d-lg-flex flex-wrap dropdown-menu-wide"> <div class="HeaderMenu-column px-lg-4 border-lg-right mb-4 mb-lg-0 pr-lg-7"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="resources-topics-heading">Topics</span> <ul class="list-style-none f5" aria-labelledby="resources-topics-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;ai&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;ai_link_resources_navbar&quot;}" href="/resources/articles/ai"> AI </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;devops&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;devops_link_resources_navbar&quot;}" href="/resources/articles/devops"> DevOps </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;security&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;security_link_resources_navbar&quot;}" href="/resources/articles/security"> Security </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;software_development&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;software_development_link_resources_navbar&quot;}" href="/resources/articles/software-development"> Software Development </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;view_all&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;view_all_link_resources_navbar&quot;}" href="/resources/articles"> View all </a></li> </ul> </div> </div> <div class="HeaderMenu-column px-lg-4"> <div class="border-bottom pb-3 pb-lg-0 border-lg-bottom-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="resources-explore-heading">Explore</span> <ul class="list-style-none f5" aria-labelledby="resources-explore-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;learning_pathways&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;learning_pathways_link_resources_navbar&quot;}" href="https://resources.github.com/learn/pathways"> Learning Pathways <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;events_amp_webinars&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;events_amp_webinars_link_resources_navbar&quot;}" href="https://resources.github.com"> Events &amp; Webinars <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;ebooks_amp_whitepapers&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;ebooks_amp_whitepapers_link_resources_navbar&quot;}" href="https://github.com/resources/whitepapers"> Ebooks &amp; Whitepapers </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;customer_stories&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;customer_stories_link_resources_navbar&quot;}" href="https://github.com/customer-stories"> Customer Stories </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary Link--external" target="_blank" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;partners&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;partners_link_resources_navbar&quot;}" href="https://partner.github.com"> Partners <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-link-external HeaderMenu-external-icon color-fg-subtle"> <path d="M3.75 2h3.5a.75.75 0 0 1 0 1.5h-3.5a.25.25 0 0 0-.25.25v8.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-3.5a.75.75 0 0 1 1.5 0v3.5A1.75 1.75 0 0 1 12.25 14h-8.5A1.75 1.75 0 0 1 2 12.25v-8.5C2 2.784 2.784 2 3.75 2Zm6.854-1h4.146a.25.25 0 0 1 .25.25v4.146a.25.25 0 0 1-.427.177L13.03 4.03 9.28 7.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.75-3.75-1.543-1.543A.25.25 0 0 1 10.604 1Z"></path> </svg> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;executive_insights&quot;,&quot;context&quot;:&quot;resources&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;executive_insights_link_resources_navbar&quot;}" href="https://github.com/solutions/executive-insights"> Executive Insights </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Open Source <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 px-lg-4"> <div class="HeaderMenu-column"> <div class="border-bottom pb-3 pb-lg-0 pb-lg-3 mb-3 mb-lg-0 mb-lg-3"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;github_sponsors&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;github_sponsors_link_open_source_navbar&quot;}" href="/sponsors"> <div> <div class="color-fg-default h4">GitHub Sponsors</div> Fund open source developers </div> </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 pb-lg-3 mb-3 mb-lg-0 mb-lg-3"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;the_readme_project&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;the_readme_project_link_open_source_navbar&quot;}" href="https://github.com/readme"> <div> <div class="color-fg-default h4">The ReadME Project</div> GitHub community articles </div> </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="open-source-repositories-heading">Repositories</span> <ul class="list-style-none f5" aria-labelledby="open-source-repositories-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;topics&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;topics_link_open_source_navbar&quot;}" href="https://github.com/topics"> Topics </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;trending&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;trending_link_open_source_navbar&quot;}" href="https://github.com/trending"> Trending </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;collections&quot;,&quot;context&quot;:&quot;open_source&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;collections_link_open_source_navbar&quot;}" href="https://github.com/collections"> Collections </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <button type="button" class="HeaderMenu-link border-0 width-full width-lg-auto px-0 px-lg-2 py-lg-2 no-wrap d-flex flex-items-center flex-justify-between js-details-target" aria-expanded="false"> Enterprise <svg opacity="0.5" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-chevron-down HeaderMenu-icon ml-1"> <path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path> </svg> </button> <div class="HeaderMenu-dropdown dropdown-menu rounded m-0 p-0 pt-2 pt-lg-4 position-relative position-lg-absolute left-0 left-lg-n3 pb-2 pb-lg-4 px-lg-4"> <div class="HeaderMenu-column"> <div class="border-bottom pb-3 pb-lg-0 pb-lg-3 mb-3 mb-lg-0 mb-lg-3"> <ul class="list-style-none f5" > <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;enterprise_platform&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;enterprise_platform_link_enterprise_navbar&quot;}" href="/enterprise"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-stack color-fg-subtle mr-3"> <path d="M11.063 1.456a1.749 1.749 0 0 1 1.874 0l8.383 5.316a1.751 1.751 0 0 1 0 2.956l-8.383 5.316a1.749 1.749 0 0 1-1.874 0L2.68 9.728a1.751 1.751 0 0 1 0-2.956Zm1.071 1.267a.25.25 0 0 0-.268 0L3.483 8.039a.25.25 0 0 0 0 .422l8.383 5.316a.25.25 0 0 0 .268 0l8.383-5.316a.25.25 0 0 0 0-.422Z"></path><path d="M1.867 12.324a.75.75 0 0 1 1.035-.232l8.964 5.685a.25.25 0 0 0 .268 0l8.964-5.685a.75.75 0 0 1 .804 1.267l-8.965 5.685a1.749 1.749 0 0 1-1.874 0l-8.965-5.685a.75.75 0 0 1-.231-1.035Z"></path><path d="M1.867 16.324a.75.75 0 0 1 1.035-.232l8.964 5.685a.25.25 0 0 0 .268 0l8.964-5.685a.75.75 0 0 1 .804 1.267l-8.965 5.685a1.749 1.749 0 0 1-1.874 0l-8.965-5.685a.75.75 0 0 1-.231-1.035Z"></path> </svg> <div> <div class="color-fg-default h4">Enterprise platform</div> AI-powered developer platform </div> </a></li> </ul> </div> <div class="border-bottom pb-3 pb-lg-0 border-bottom-0"> <span class="d-block h4 color-fg-default my-1" id="enterprise-available-add-ons-heading">Available add-ons</span> <ul class="list-style-none f5" aria-labelledby="enterprise-available-add-ons-heading"> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;advanced_security&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;advanced_security_link_enterprise_navbar&quot;}" href="https://github.com/enterprise/advanced-security"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-shield-check color-fg-subtle mr-3"> <path d="M16.53 9.78a.75.75 0 0 0-1.06-1.06L11 13.19l-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5Z"></path><path d="m12.54.637 8.25 2.675A1.75 1.75 0 0 1 22 4.976V10c0 6.19-3.771 10.704-9.401 12.83a1.704 1.704 0 0 1-1.198 0C5.77 20.705 2 16.19 2 10V4.976c0-.758.489-1.43 1.21-1.664L11.46.637a1.748 1.748 0 0 1 1.08 0Zm-.617 1.426-8.25 2.676a.249.249 0 0 0-.173.237V10c0 5.46 3.28 9.483 8.43 11.426a.199.199 0 0 0 .14 0C17.22 19.483 20.5 15.461 20.5 10V4.976a.25.25 0 0 0-.173-.237l-8.25-2.676a.253.253 0 0 0-.154 0Z"></path> </svg> <div> <div class="color-fg-default h4">Advanced Security</div> Enterprise-grade security features </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description pb-lg-3" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;copilot_for_business&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;copilot_for_business_link_enterprise_navbar&quot;}" href="/features/copilot/copilot-business"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-copilot color-fg-subtle mr-3"> <path d="M23.922 16.992c-.861 1.495-5.859 5.023-11.922 5.023-6.063 0-11.061-3.528-11.922-5.023A.641.641 0 0 1 0 16.736v-2.869a.841.841 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.195 10.195 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952 1.399-1.136 3.392-2.093 6.122-2.093 2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.832.832 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256ZM12.172 11h-.344a4.323 4.323 0 0 1-.355.508C10.703 12.455 9.555 13 7.965 13c-1.725 0-2.989-.359-3.782-1.259a2.005 2.005 0 0 1-.085-.104L4 11.741v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.323 4.323 0 0 1-.355-.508h-.016.016Zm.641-2.935c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z"></path><path d="M14.5 14.25a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Zm-5 0a1 1 0 0 1 1 1v2a1 1 0 0 1-2 0v-2a1 1 0 0 1 1-1Z"></path> </svg> <div> <div class="color-fg-default h4">Copilot for business</div> Enterprise-grade AI features </div> </a></li> <li> <a class="HeaderMenu-dropdown-link d-block no-underline position-relative py-2 Link--secondary d-flex flex-items-center Link--has-description" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;premium_support&quot;,&quot;context&quot;:&quot;enterprise&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;premium_support_link_enterprise_navbar&quot;}" href="/premium-support"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-comment-discussion color-fg-subtle mr-3"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1ZM1.5 2.75v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z"></path><path d="M22.5 8.75a.25.25 0 0 0-.25-.25h-3.5a.75.75 0 0 1 0-1.5h3.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 22.25 20H21v1.543a1.457 1.457 0 0 1-2.487 1.03L15.939 20H10.75A1.75 1.75 0 0 1 9 18.25v-1.465a.75.75 0 0 1 1.5 0v1.465c0 .138.112.25.25.25h5.5a.75.75 0 0 1 .53.22l2.72 2.72v-2.19a.75.75 0 0 1 .75-.75h2a.25.25 0 0 0 .25-.25v-9.5Z"></path> </svg> <div> <div class="color-fg-default h4">Premium Support</div> Enterprise-grade 24/7 support </div> </a></li> </ul> </div> </div> </div> </li> <li class="HeaderMenu-item position-relative flex-wrap flex-justify-between flex-items-center d-block d-lg-flex flex-lg-nowrap flex-lg-items-center js-details-container js-header-menu-item"> <a class="HeaderMenu-link no-underline px-0 px-lg-2 py-3 py-lg-2 d-block d-lg-inline-block" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;pricing&quot;,&quot;context&quot;:&quot;global&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;pricing_link_global_navbar&quot;}" href="https://github.com/pricing">Pricing</a> </li> </ul> </nav> <div class="d-flex flex-column flex-lg-row width-full flex-justify-end flex-lg-items-center text-center mt-3 mt-lg-0 text-lg-left ml-lg-3"> <qbsearch-input class="search-input" data-scope="repo:python/peps" data-custom-scopes-path="/search/custom_scopes" data-delete-custom-scopes-csrf="2gmXbwm7LcuSa7VnKdan8hb01DTnBGvDdyGUf55zGZ6xoz_wJnlpa9NcAmLkDTTtHo2tdRZAQA8zNcIJCFWMUA" data-max-custom-scopes="10" data-header-redesign-enabled="false" data-initial-value="" data-blackbird-suggestions-path="/search/suggestions" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" data-current-repository="python/peps" data-current-org="python" data-current-owner="" data-logged-in="false" data-copilot-chat-enabled="false" data-nl-search-enabled="false" data-retain-scroll-position="true"> <div class="search-input-container search-with-dialog position-relative d-flex flex-row flex-items-center mr-4 rounded" data-action="click:qbsearch-input#searchInputContainerClicked" > <button type="button" class="header-search-button placeholder input-button form-control d-flex flex-1 flex-self-stretch flex-items-center no-wrap width-full py-0 pl-2 pr-0 text-left border-0 box-shadow-none" data-target="qbsearch-input.inputButton" aria-label="Search or jump to…" aria-haspopup="dialog" placeholder="Search or jump to..." data-hotkey=s,/ autocapitalize="off" data-analytics-event="{&quot;location&quot;:&quot;navbar&quot;,&quot;action&quot;:&quot;searchbar&quot;,&quot;context&quot;:&quot;global&quot;,&quot;tag&quot;:&quot;input&quot;,&quot;label&quot;:&quot;searchbar_input_global_navbar&quot;}" data-action="click:qbsearch-input#handleExpand" > <div class="mr-2 color-fg-muted"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path> </svg> </div> <span class="flex-1" data-target="qbsearch-input.inputButtonText">Search or jump to...</span> <div class="d-flex" data-target="qbsearch-input.hotkeyIndicator"> <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> </div> </button> <input type="hidden" name="type" class="js-site-search-type-field"> <div class="Overlay--hidden " data-modal-dialog-overlay> <modal-dialog data-action="close:qbsearch-input#handleClose cancel:qbsearch-input#handleClose" data-target="qbsearch-input.searchSuggestionsDialog" role="dialog" id="search-suggestions-dialog" aria-modal="true" aria-labelledby="search-suggestions-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto"> <h1 id="search-suggestions-dialog-header" class="sr-only">Search code, repositories, users, issues, pull requests...</h1> <div class="Overlay-body Overlay-body--paddingNone"> <div data-view-component="true"> <div class="search-suggestions position-fixed width-full color-shadow-large border color-fg-default color-bg-default overflow-hidden d-flex flex-column query-builder-container" style="border-radius: 12px;" data-target="qbsearch-input.queryBuilderContainer" hidden > <!-- '"` --><!-- </textarea></xmp> --></option></form><form id="query-builder-test-form" action="" accept-charset="UTF-8" method="get"> <query-builder data-target="qbsearch-input.queryBuilder" id="query-builder-query-builder-test" data-filter-key=":" data-view-component="true" class="QueryBuilder search-query-builder"> <div class="FormControl FormControl--fullWidth"> <label id="query-builder-test-label" for="query-builder-test" class="FormControl-label sr-only"> Search </label> <div class="QueryBuilder-StyledInput width-fit " data-target="query-builder.styledInput" > <span id="query-builder-test-leadingvisual-wrap" class="FormControl-input-leadingVisualWrap QueryBuilder-leadingVisualWrap"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search FormControl-input-leadingVisual"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path> </svg> </span> <div data-target="query-builder.styledInputContainer" class="QueryBuilder-StyledInputContainer"> <div aria-hidden="true" class="QueryBuilder-StyledInputContent" data-target="query-builder.styledInputContent" ></div> <div class="QueryBuilder-InputWrapper"> <div aria-hidden="true" class="QueryBuilder-Sizer" data-target="query-builder.sizer"></div> <input id="query-builder-test" name="query-builder-test" value="" autocomplete="off" type="text" role="combobox" spellcheck="false" aria-expanded="false" aria-describedby="validation-4a2337f7-1c18-4a10-a7fc-2234a84effd2" data-target="query-builder.input" data-action=" input:query-builder#inputChange blur:query-builder#inputBlur keydown:query-builder#inputKeydown focus:query-builder#inputFocus " data-view-component="true" class="FormControl-input QueryBuilder-Input FormControl-medium" /> </div> </div> <span class="sr-only" id="query-builder-test-clear">Clear</span> <button role="button" id="query-builder-test-clear-button" aria-labelledby="query-builder-test-clear query-builder-test-label" data-target="query-builder.clearButton" data-action=" click:query-builder#clear focus:query-builder#clearButtonFocus blur:query-builder#clearButtonBlur " variant="small" hidden="hidden" type="button" data-view-component="true" class="Button Button--iconOnly Button--invisible Button--medium mr-1 px-2 py-0 d-flex flex-items-center rounded-1 color-fg-muted"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x-circle-fill Button-visual"> <path d="M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z"></path> </svg> </button> </div> <template id="search-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path> </svg> </template> <template id="code-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path> </svg> </template> <template id="file-code-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-code"> <path d="M4 1.75C4 .784 4.784 0 5.75 0h5.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 14.25 15h-9a.75.75 0 0 1 0-1.5h9a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 10 4.25V1.5H5.75a.25.25 0 0 0-.25.25v2.5a.75.75 0 0 1-1.5 0Zm1.72 4.97a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l1.47-1.47-1.47-1.47a.75.75 0 0 1 0-1.06ZM3.28 7.78 1.81 9.25l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Zm8.22-6.218V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path> </svg> </template> <template id="history-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history"> <path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path> </svg> </template> <template id="repo-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path> </svg> </template> <template id="bookmark-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bookmark"> <path d="M3 2.75C3 1.784 3.784 1 4.75 1h6.5c.966 0 1.75.784 1.75 1.75v11.5a.75.75 0 0 1-1.227.579L8 11.722l-3.773 3.107A.751.751 0 0 1 3 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.91l3.023-2.489a.75.75 0 0 1 .954 0l3.023 2.49V2.75a.25.25 0 0 0-.25-.25Z"></path> </svg> </template> <template id="plus-circle-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-plus-circle"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7.25-3.25v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5a.75.75 0 0 1 1.5 0Z"></path> </svg> </template> <template id="circle-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-dot-fill"> <path d="M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"></path> </svg> </template> <template id="trash-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-trash"> <path d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"></path> </svg> </template> <template id="team-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-people"> <path d="M2 5.5a3.5 3.5 0 1 1 5.898 2.549 5.508 5.508 0 0 1 3.034 4.084.75.75 0 1 1-1.482.235 4 4 0 0 0-7.9 0 .75.75 0 0 1-1.482-.236A5.507 5.507 0 0 1 3.102 8.05 3.493 3.493 0 0 1 2 5.5ZM11 4a3.001 3.001 0 0 1 2.22 5.018 5.01 5.01 0 0 1 2.56 3.012.749.749 0 0 1-.885.954.752.752 0 0 1-.549-.514 3.507 3.507 0 0 0-2.522-2.372.75.75 0 0 1-.574-.73v-.352a.75.75 0 0 1 .416-.672A1.5 1.5 0 0 0 11 5.5.75.75 0 0 1 11 4Zm-5.5-.5a2 2 0 1 0-.001 3.999A2 2 0 0 0 5.5 3.5Z"></path> </svg> </template> <template id="project-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path> </svg> </template> <template id="pencil-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-pencil"> <path d="M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z"></path> </svg> </template> <template id="copilot-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copilot"> <path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path> </svg> </template> <template id="copilot-error-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copilot-error"> <path d="M16 11.24c0 .112-.072.274-.21.467L13 9.688V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-.198 0-.388-.009-.571-.029L6.833 5.226a4.01 4.01 0 0 0 .17-.782c.117-.935-.037-1.395-.241-1.614-.193-.206-.637-.413-1.682-.297-.683.076-1.115.231-1.395.415l-1.257-.91c.579-.564 1.413-.877 2.485-.996 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095Zm-5.083-8.707c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Zm2.511 11.074c-1.393.776-3.272 1.428-5.43 1.428-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.18-.455-.241-.963-.252-1.475L.31 4.107A.747.747 0 0 1 0 3.509V3.49a.748.748 0 0 1 .625-.73c.156-.026.306.047.435.139l14.667 10.578a.592.592 0 0 1 .227.264.752.752 0 0 1 .046.249v.022a.75.75 0 0 1-1.19.596Zm-1.367-.991L5.635 7.964a5.128 5.128 0 0 1-.889.073c-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433 1.539 0 3.089-.505 4.063-.934Z"></path> </svg> </template> <template id="workflow-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-workflow"> <path d="M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"></path> </svg> </template> <template id="book-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-book"> <path d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"></path> </svg> </template> <template id="code-review-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code-review"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z"></path> </svg> </template> <template id="codespaces-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-codespaces"> <path d="M0 11.25c0-.966.784-1.75 1.75-1.75h12.5c.966 0 1.75.784 1.75 1.75v3A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm2-9.5C2 .784 2.784 0 3.75 0h8.5C13.216 0 14 .784 14 1.75v5a1.75 1.75 0 0 1-1.75 1.75h-8.5A1.75 1.75 0 0 1 2 6.75Zm1.75-.25a.25.25 0 0 0-.25.25v5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-5a.25.25 0 0 0-.25-.25Zm-2 9.5a.25.25 0 0 0-.25.25v3c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-3a.25.25 0 0 0-.25-.25Z"></path><path d="M7 12.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Zm-4 0a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75Z"></path> </svg> </template> <template id="comment-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-comment"> <path d="M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path> </svg> </template> <template id="comment-discussion-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-comment-discussion"> <path d="M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.061l-2.574 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.458 1.458 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h1a.25.25 0 0 0 .25-.25Z"></path> </svg> </template> <template id="organization-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-organization"> <path d="M1.75 16A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0h8.5C11.216 0 12 .784 12 1.75v12.5c0 .085-.006.168-.018.25h2.268a.25.25 0 0 0 .25-.25V8.285a.25.25 0 0 0-.111-.208l-1.055-.703a.749.749 0 1 1 .832-1.248l1.055.703c.487.325.779.871.779 1.456v5.965A1.75 1.75 0 0 1 14.25 16h-3.5a.766.766 0 0 1-.197-.026c-.099.017-.2.026-.303.026h-3a.75.75 0 0 1-.75-.75V14h-1v1.25a.75.75 0 0 1-.75.75Zm-.25-1.75c0 .138.112.25.25.25H4v-1.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 .75.75v1.25h2.25a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25ZM3.75 6h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM3 3.75A.75.75 0 0 1 3.75 3h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 3.75Zm4 3A.75.75 0 0 1 7.75 6h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 7 6.75ZM7.75 3h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM3 9.75A.75.75 0 0 1 3.75 9h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 9.75ZM7.75 9h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5Z"></path> </svg> </template> <template id="rocket-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-rocket"> <path d="M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> </template> <template id="shield-check-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield-check"> <path d="m8.533.133 5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667l5.25-1.68a1.748 1.748 0 0 1 1.066 0Zm-.61 1.429.001.001-5.25 1.68a.251.251 0 0 0-.174.237V7c0 1.36.275 2.666 1.057 3.859.784 1.194 2.121 2.342 4.366 3.298a.196.196 0 0 0 .154 0c2.245-.957 3.582-2.103 4.366-3.297C13.225 9.666 13.5 8.358 13.5 7V3.48a.25.25 0 0 0-.174-.238l-5.25-1.68a.25.25 0 0 0-.153 0ZM11.28 6.28l-3.5 3.5a.75.75 0 0 1-1.06 0l-1.5-1.5a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l.97.97 2.97-2.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> </template> <template id="heart-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-heart"> <path d="m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002ZM4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.58 20.58 0 0 0 8 13.393a20.58 20.58 0 0 0 3.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.749.749 0 0 1-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5Z"></path> </svg> </template> <template id="server-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-server"> <path d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v4c0 .372-.116.717-.314 1 .198.283.314.628.314 1v4a1.75 1.75 0 0 1-1.75 1.75H1.75A1.75 1.75 0 0 1 0 12.75v-4c0-.358.109-.707.314-1a1.739 1.739 0 0 1-.314-1v-4C0 1.784.784 1 1.75 1ZM1.5 2.75v4c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm.25 5.75a.25.25 0 0 0-.25.25v4c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4a.25.25 0 0 0-.25-.25ZM7 4.75A.75.75 0 0 1 7.75 4h4.5a.75.75 0 0 1 0 1.5h-4.5A.75.75 0 0 1 7 4.75ZM7.75 10h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM3 4.75A.75.75 0 0 1 3.75 4h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 4.75ZM3.75 10h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5Z"></path> </svg> </template> <template id="globe-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-globe"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM5.78 8.75a9.64 9.64 0 0 0 1.363 4.177c.255.426.542.832.857 1.215.245-.296.551-.705.857-1.215A9.64 9.64 0 0 0 10.22 8.75Zm4.44-1.5a9.64 9.64 0 0 0-1.363-4.177c-.307-.51-.612-.919-.857-1.215a9.927 9.927 0 0 0-.857 1.215A9.64 9.64 0 0 0 5.78 7.25Zm-5.944 1.5H1.543a6.507 6.507 0 0 0 4.666 5.5c-.123-.181-.24-.365-.352-.552-.715-1.192-1.437-2.874-1.581-4.948Zm-2.733-1.5h2.733c.144-2.074.866-3.756 1.58-4.948.12-.197.237-.381.353-.552a6.507 6.507 0 0 0-4.666 5.5Zm10.181 1.5c-.144 2.074-.866 3.756-1.58 4.948-.12.197-.237.381-.353.552a6.507 6.507 0 0 0 4.666-5.5Zm2.733-1.5a6.507 6.507 0 0 0-4.666-5.5c.123.181.24.365.353.552.714 1.192 1.436 2.874 1.58 4.948Z"></path> </svg> </template> <template id="issue-opened-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path> </svg> </template> <template id="device-mobile-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-device-mobile"> <path d="M3.75 0h8.5C13.216 0 14 .784 14 1.75v12.5A1.75 1.75 0 0 1 12.25 16h-8.5A1.75 1.75 0 0 1 2 14.25V1.75C2 .784 2.784 0 3.75 0ZM3.5 1.75v12.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25ZM8 13a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path> </svg> </template> <template id="package-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-package"> <path d="m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"></path> </svg> </template> <template id="credit-card-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-credit-card"> <path d="M10.75 9a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5h-1.5Z"></path><path d="M0 3.75C0 2.784.784 2 1.75 2h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25ZM14.5 6.5h-13v5.75c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25Zm0-2.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25V5h13Z"></path> </svg> </template> <template id="play-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path> </svg> </template> <template id="gift-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-gift"> <path d="M2 2.75A2.75 2.75 0 0 1 4.75 0c.983 0 1.873.42 2.57 1.232.268.318.497.668.68 1.042.183-.375.411-.725.68-1.044C9.376.42 10.266 0 11.25 0a2.75 2.75 0 0 1 2.45 4h.55c.966 0 1.75.784 1.75 1.75v2c0 .698-.409 1.301-1 1.582v4.918A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V9.332C.409 9.05 0 8.448 0 7.75v-2C0 4.784.784 4 1.75 4h.55c-.192-.375-.3-.8-.3-1.25ZM7.25 9.5H2.5v4.75c0 .138.112.25.25.25h4.5Zm1.5 0v5h4.5a.25.25 0 0 0 .25-.25V9.5Zm0-4V8h5.5a.25.25 0 0 0 .25-.25v-2a.25.25 0 0 0-.25-.25Zm-7 0a.25.25 0 0 0-.25.25v2c0 .138.112.25.25.25h5.5V5.5h-5.5Zm3-4a1.25 1.25 0 0 0 0 2.5h2.309c-.233-.818-.542-1.401-.878-1.793-.43-.502-.915-.707-1.431-.707ZM8.941 4h2.309a1.25 1.25 0 0 0 0-2.5c-.516 0-1 .205-1.43.707-.337.392-.646.975-.879 1.793Z"></path> </svg> </template> <template id="code-square-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code-square"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm7.47 3.97a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L10.69 8 9.22 6.53a.75.75 0 0 1 0-1.06ZM6.78 6.53 5.31 8l1.47 1.47a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-2-2a.75.75 0 0 1 0-1.06l2-2a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> </template> <template id="device-desktop-icon"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-device-desktop"> <path d="M14.25 1c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 14.25 12h-3.727c.099 1.041.52 1.872 1.292 2.757A.752.752 0 0 1 11.25 16h-6.5a.75.75 0 0 1-.565-1.243c.772-.885 1.192-1.716 1.292-2.757H1.75A1.75 1.75 0 0 1 0 10.25v-7.5C0 1.784.784 1 1.75 1ZM1.75 2.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25ZM9.018 12H6.982a5.72 5.72 0 0 1-.765 2.5h3.566a5.72 5.72 0 0 1-.765-2.5Z"></path> </svg> </template> <div class="position-relative"> <ul role="listbox" class="ActionListWrap QueryBuilder-ListWrap" aria-label="Suggestions" data-action=" combobox-commit:query-builder#comboboxCommit mousedown:query-builder#resultsMousedown " data-target="query-builder.resultsList" data-persist-list=false id="query-builder-test-results" ></ul> </div> <div class="FormControl-inlineValidation" id="validation-4a2337f7-1c18-4a10-a7fc-2234a84effd2" hidden="hidden"> <span class="FormControl-inlineValidation--visual"> <svg aria-hidden="true" height="12" viewBox="0 0 12 12" version="1.1" width="12" data-view-component="true" class="octicon octicon-alert-fill"> <path d="M4.855.708c.5-.896 1.79-.896 2.29 0l4.675 8.351a1.312 1.312 0 0 1-1.146 1.954H1.33A1.313 1.313 0 0 1 .183 9.058ZM7 7V3H5v4Zm-1 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"></path> </svg> </span> <span></span> </div> </div> <div data-target="query-builder.screenReaderFeedback" aria-live="polite" aria-atomic="true" class="sr-only"></div> </query-builder></form> <div class="d-flex flex-row color-fg-muted px-3 text-small color-bg-default search-feedback-prompt"> <a target="_blank" href="https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax" data-view-component="true" class="Link color-fg-accent text-normal ml-2">Search syntax tips</a> <div class="d-flex flex-1"></div> </div> </div> </div> </div> </modal-dialog></div> </div> <div data-action="click:qbsearch-input#retract" class="dark-backdrop position-fixed" hidden data-target="qbsearch-input.darkBackdrop"></div> <div class="color-fg-default"> <dialog-helper> <dialog data-target="qbsearch-input.feedbackDialog" data-action="close:qbsearch-input#handleDialogClose cancel:qbsearch-input#handleDialogClose" id="feedback-dialog" aria-modal="true" aria-labelledby="feedback-dialog-title" aria-describedby="feedback-dialog-description" data-view-component="true" class="Overlay Overlay-whenNarrow Overlay--size-medium Overlay--motion-scaleFade Overlay--disableScroll"> <div data-view-component="true" class="Overlay-header"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 class="Overlay-title " id="feedback-dialog-title"> Provide feedback </h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="feedback-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg></button> </div> </div> </div> <scrollable-region data-labelled-by="feedback-dialog-title"> <div data-view-component="true" class="Overlay-body"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form id="code-search-feedback-form" data-turbo="false" action="/search/feedback" accept-charset="UTF-8" method="post"><input type="hidden" data-csrf="true" name="authenticity_token" value="x/mvODdmYhURay6KDEAYusH77XviZbp48zoq1YIovbk3KC/CluVkYk53HB0kTd624LFhw8NscucK8u9Z5VeICQ==" /> <p>We read every piece of feedback, and take your input very seriously.</p> <textarea name="feedback" class="form-control width-full mb-2" style="height: 120px" id="feedback"></textarea> <input name="include_email" id="include_email" aria-label="Include my email address so I can be contacted" class="form-control mr-2" type="checkbox"> <label for="include_email" style="font-weight: normal">Include my email address so I can be contacted</label> </form></div> </scrollable-region> <div data-view-component="true" class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="feedback-dialog" type="button" data-view-component="true" class="btn"> Cancel </button> <button form="code-search-feedback-form" data-action="click:qbsearch-input#submitFeedback" type="submit" data-view-component="true" class="btn-primary btn"> Submit feedback </button> </div> </dialog></dialog-helper> <custom-scopes data-target="qbsearch-input.customScopesManager"> <dialog-helper> <dialog data-target="custom-scopes.customScopesModalDialog" data-action="close:qbsearch-input#handleDialogClose cancel:qbsearch-input#handleDialogClose" id="custom-scopes-dialog" aria-modal="true" aria-labelledby="custom-scopes-dialog-title" aria-describedby="custom-scopes-dialog-description" data-view-component="true" class="Overlay Overlay-whenNarrow Overlay--size-medium Overlay--motion-scaleFade Overlay--disableScroll"> <div data-view-component="true" class="Overlay-header Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 class="Overlay-title " id="custom-scopes-dialog-title"> Saved searches </h1> <h2 id="custom-scopes-dialog-description" class="Overlay-description">Use saved searches to filter your results more quickly</h2> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="custom-scopes-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg></button> </div> </div> </div> <scrollable-region data-labelled-by="custom-scopes-dialog-title"> <div data-view-component="true" class="Overlay-body"> <div data-target="custom-scopes.customScopesModalDialogFlash"></div> <div hidden class="create-custom-scope-form" data-target="custom-scopes.createCustomScopeForm"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form id="custom-scopes-dialog-form" data-turbo="false" action="/search/custom_scopes" accept-charset="UTF-8" method="post"><input type="hidden" data-csrf="true" name="authenticity_token" value="6zxMZWs3Aza6vGArqtEsFi8s8EW40kJe4BdmdL4YFO46sEs4B9ao5H0fLURqGJJHB8mgDR++G6OGTktk6aiGeg==" /> <div data-target="custom-scopes.customScopesModalDialogFlash"></div> <input type="hidden" id="custom_scope_id" name="custom_scope_id" data-target="custom-scopes.customScopesIdField"> <div class="form-group"> <label for="custom_scope_name">Name</label> <auto-check src="/search/custom_scopes/check_name" required only-validate-on-blur="false"> <input type="text" name="custom_scope_name" id="custom_scope_name" data-target="custom-scopes.customScopesNameField" class="form-control" autocomplete="off" placeholder="github-ruby" required maxlength="50"> <input type="hidden" data-csrf="true" value="XmuyPOgcxxEAGgY+aAnfBaESdFhEaTYjgYj8GBzqX/DJ50YU9Lj78++H/4EEQ69qf1b1mc6G8+GFntus6pm17A==" /> </auto-check> </div> <div class="form-group"> <label for="custom_scope_query">Query</label> <input type="text" name="custom_scope_query" id="custom_scope_query" data-target="custom-scopes.customScopesQueryField" class="form-control" autocomplete="off" placeholder="(repo:mona/a OR repo:mona/b) AND lang:python" required maxlength="500"> </div> <p class="text-small color-fg-muted"> To see all available qualifiers, see our <a class="Link--inTextBlock" href="https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax">documentation</a>. </p> </form> </div> <div data-target="custom-scopes.manageCustomScopesForm"> <div data-target="custom-scopes.list"></div> </div> </div> </scrollable-region> <div data-view-component="true" class="Overlay-footer Overlay-footer--alignEnd Overlay-footer--divided"> <button data-action="click:custom-scopes#customScopesCancel" type="button" data-view-component="true" class="btn"> Cancel </button> <button form="custom-scopes-dialog-form" data-action="click:custom-scopes#customScopesSubmit" data-target="custom-scopes.customScopesSubmitButton" type="submit" data-view-component="true" class="btn-primary btn"> Create saved search </button> </div> </dialog></dialog-helper> </custom-scopes> </div> </qbsearch-input> <div class="position-relative HeaderMenu-link-wrap d-lg-inline-block"> <a href="/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fpeps%2Fblob%2Fmain%2Fpeps%2Fpep-0622.rst" class="HeaderMenu-link HeaderMenu-link--sign-in HeaderMenu-button flex-shrink-0 no-underline d-none d-lg-inline-flex border border-lg-0 rounded rounded-lg-0 px-2 py-1" style="margin-left: 12px;" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/python/peps/blob/main/peps/pep-0622.rst&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="e07bcba36c1f06f8020123a139fd0d9e546d47cd71466ea4fb3f4492328c426c" data-analytics-event="{&quot;category&quot;:&quot;Marketing nav&quot;,&quot;action&quot;:&quot;click to go to homepage&quot;,&quot;label&quot;:&quot;ref_page:Marketing;ref_cta:Sign in;ref_loc:Header&quot;}" > Sign in </a> </div> <a href="/signup?ref_cta=Sign+up&amp;ref_loc=header+logged+out&amp;ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fblob%2Fshow&amp;source=header-repo&amp;source_repo=python%2Fpeps" class="HeaderMenu-link HeaderMenu-link--sign-up HeaderMenu-button flex-shrink-0 d-flex d-lg-inline-flex no-underline border color-border-default rounded px-2 py-1" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;originating_url&quot;:&quot;https://github.com/python/peps/blob/main/peps/pep-0622.rst&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="e07bcba36c1f06f8020123a139fd0d9e546d47cd71466ea4fb3f4492328c426c" data-analytics-event="{&quot;category&quot;:&quot;Sign up&quot;,&quot;action&quot;:&quot;click to sign up for account&quot;,&quot;label&quot;:&quot;ref_page:/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show;ref_cta:Sign up;ref_loc:header logged out&quot;}" > Sign up </a> <button type="button" class="sr-only js-header-menu-focus-trap d-block d-lg-none">Reseting focus</button> </div> </div> </div> </div> </header> <div hidden="hidden" data-view-component="true" class="js-stale-session-flash stale-session-flash flash flash-warn flash-full"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> <span class="js-stale-session-flash-signed-in" hidden>You signed in with another tab or window. <a class="Link--inTextBlock" href="">Reload</a> to refresh your session.</span> <span class="js-stale-session-flash-signed-out" hidden>You signed out in another tab or window. <a class="Link--inTextBlock" href="">Reload</a> to refresh your session.</span> <span class="js-stale-session-flash-switched" hidden>You switched accounts on another tab or window. <a class="Link--inTextBlock" href="">Reload</a> to refresh your session.</span> <button id="icon-button-40cef1fb-83f6-48ea-82d5-ca5666cf6929" aria-labelledby="tooltip-75035fd5-f556-40bb-9a32-48f660f1167e" type="button" data-view-component="true" class="Button Button--iconOnly Button--invisible Button--medium flash-close js-flash-close"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x Button-visual"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button><tool-tip id="tooltip-75035fd5-f556-40bb-9a32-48f660f1167e" for="icon-button-40cef1fb-83f6-48ea-82d5-ca5666cf6929" popover="manual" data-direction="s" data-type="label" data-view-component="true" class="sr-only position-absolute">Dismiss alert</tool-tip> </div> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" class="flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div> </div> </template> </div> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled data-project-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--page-header-bgColor, var(--color-page-header-bg));" data-turbo-replace> <div class="d-flex flex-nowrap flex-justify-end mb-3 px-3 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path> </svg> <span class="author flex-self-stretch" itemprop="author"> <a class="url fn" rel="author" data-hovercard-type="organization" data-hovercard-url="/orgs/python/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/python"> python </a> </span> <span class="mx-1 flex-self-stretch color-fg-muted">/</span> <strong itemprop="name" class="mr-2 flex-self-stretch"> <a data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" href="/python/peps">peps</a> </strong> <span></span><span class="Label Label--secondary v-align-middle mr-1">Public</span> </div> </div> <div id="repository-details-container" class="flex-shrink-0" data-turbo-replace style="max-width: 70%;"> <ul class="pagehead-actions flex-shrink-0 d-none d-md-inline" style="padding: 2px 0;"> <li> <include-fragment src="/python/peps/sponsor_button"></include-fragment> </li> <li> <a href="/login?return_to=%2Fpython%2Fpeps" rel="nofollow" id="repository-details-watch-button" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;notification subscription menu watch&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/python/peps/blob/main/peps/pep-0622.rst&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="d89b7daa2a1572da2f7baaae1eb999016e8e43a6827092d69c3f25252ba99241" aria-label="You must be signed in to change notification settings" data-view-component="true" class="btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path> </svg>Notifications </a> <tool-tip id="tooltip-6840bff8-f9cd-4132-9314-6b44c93dc16f" for="repository-details-watch-button" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">You must be signed in to change notification settings</tool-tip> </li> <li> <a icon="repo-forked" id="fork-button" href="/login?return_to=%2Fpython%2Fpeps" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;repo details fork button&quot;,&quot;repository_id&quot;:13414105,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/python/peps/blob/main/peps/pep-0622.rst&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="22ce5f02028ac582c5254132ffd3102a6c99aacc1ca820386b99f107311d724a" data-view-component="true" class="btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path> </svg>Fork <span id="repo-network-counter" data-pjax-replace="true" data-turbo-replace="true" title="1,582" data-view-component="true" class="Counter">1.6k</span> </a> </li> <li> <div data-view-component="true" class="BtnGroup d-flex"> <a href="/login?return_to=%2Fpython%2Fpeps" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;star button&quot;,&quot;repository_id&quot;:13414105,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;originating_url&quot;:&quot;https://github.com/python/peps/blob/main/peps/pep-0622.rst&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="77a365e706b92c74854d4cb466ff1a17a0c032e18cce01f64228e10780d23e3d" aria-label="You must be signed in to star a repository" data-view-component="true" class="tooltipped tooltipped-sw btn-sm btn"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path> </svg><span data-view-component="true" class="d-inline"> Star </span> <span id="repo-stars-counter-star" aria-label="4566 users starred this repository" data-singular-suffix="user starred this repository" data-plural-suffix="users starred this repository" data-turbo-replace="true" title="4,566" data-view-component="true" class="Counter js-social-count">4.6k</span> </a></div> </li> </ul> </div> </div> <div id="responsive-meta-container" data-turbo-replace> </div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <ul data-view-component="true" class="UnderlineNav-body list-style-none"> <li data-view-component="true" class="d-inline-flex"> <a id="code-tab" href="/python/peps" data-tab-item="i0code-tab" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages repo_deployments repo_attestations /python/peps" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g c" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Code&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" aria-current="page" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item selected"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path> </svg> <span data-content="Code">Code</span> <span id="code-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="issues-tab" href="/python/peps/issues" data-tab-item="i1issues-tab" data-selected-links="repo_issues repo_labels repo_milestones /python/peps/issues" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g i" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Issues&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path> </svg> <span data-content="Issues">Issues</span> <span id="issues-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="20" data-view-component="true" class="Counter">20</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="pull-requests-tab" href="/python/peps/pulls" data-tab-item="i2pull-requests-tab" data-selected-links="repo_pulls checks /python/peps/pulls" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g p" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Pull requests&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path> </svg> <span data-content="Pull requests">Pull requests</span> <span id="pull-requests-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="33" data-view-component="true" class="Counter">33</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="actions-tab" href="/python/peps/actions" data-tab-item="i3actions-tab" data-selected-links="repo_actions /python/peps/actions" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g a" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Actions&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path> </svg> <span data-content="Actions">Actions</span> <span id="actions-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="security-tab" href="/python/peps/security" data-tab-item="i4security-tab" data-selected-links="security overview alerts policy token_scanning code_scanning /python/peps/security" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-hotkey="g s" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Security&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> <span data-content="Security">Security</span> <include-fragment src="/python/peps/security/overall-count" accept="text/fragment+html"></include-fragment> </a></li> <li data-view-component="true" class="d-inline-flex"> <a id="insights-tab" href="/python/peps/pulse" data-tab-item="i5insights-tab" data-selected-links="repo_graphs repo_contributors dependency_graph dependabot_updates pulse people community /python/peps/pulse" data-pjax="#repo-content-pjax-container" data-turbo-frame="repo-content-turbo-frame" data-analytics-event="{&quot;category&quot;:&quot;Underline navbar&quot;,&quot;action&quot;:&quot;Click tab&quot;,&quot;label&quot;:&quot;Insights&quot;,&quot;target&quot;:&quot;UNDERLINE_NAV.TAB&quot;}" data-view-component="true" class="UnderlineNav-item no-wrap js-responsive-underlinenav-item js-selected-navigation-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> <span data-content="Insights">Insights</span> <span id="insights-repo-tab-count" data-pjax-replace="" data-turbo-replace="" title="Not available" data-view-component="true" class="Counter"></span> </a></li> </ul> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <action-menu data-select-variant="none" data-view-component="true"> <focus-group direction="vertical" mnemonics retain> <button id="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-button" popovertarget="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-overlay" aria-controls="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-list" aria-haspopup="true" aria-labelledby="tooltip-8444dae8-35bb-4574-a5f9-097c69c5dc34" type="button" data-view-component="true" class="Button Button--iconOnly Button--secondary Button--medium UnderlineNav-item"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal Button-visual"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path> </svg> </button><tool-tip id="tooltip-8444dae8-35bb-4574-a5f9-097c69c5dc34" for="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-button" popover="manual" data-direction="s" data-type="label" data-view-component="true" class="sr-only position-absolute">Additional navigation options</tool-tip> <anchored-position data-target="action-menu.overlay" id="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-overlay" anchor="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-button" align="start" side="outside-bottom" anchor-offset="normal" popover="auto" data-view-component="true"> <div data-view-component="true" class="Overlay Overlay--size-auto"> <div data-view-component="true" class="Overlay-body Overlay-body--paddingNone"> <action-list> <div data-view-component="true"> <ul aria-labelledby="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-button" id="action-menu-c2397c70-caa6-4e19-a8dc-95dd2cd34116-list" role="menu" data-view-component="true" class="ActionListWrap--inset ActionListWrap"> <li hidden="hidden" data-menu-item="i0code-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-9f8b122e-4294-4df3-bace-847827191139" href="/python/peps" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Code </span> </a> </li> <li hidden="hidden" data-menu-item="i1issues-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-c6b5e3d3-c8a9-430e-beaa-3717a6e02ddb" href="/python/peps/issues" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Issues </span> </a> </li> <li hidden="hidden" data-menu-item="i2pull-requests-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-7781933b-72a9-4f6b-995e-cc5a2a4412f2" href="/python/peps/pulls" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Pull requests </span> </a> </li> <li hidden="hidden" data-menu-item="i3actions-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-eabb79de-298b-4987-af43-6d8e400ff5d7" href="/python/peps/actions" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Actions </span> </a> </li> <li hidden="hidden" data-menu-item="i4security-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-70dce39a-5059-4193-9ca3-fcaffaf56025" href="/python/peps/security" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Security </span> </a> </li> <li hidden="hidden" data-menu-item="i5insights-tab" data-targets="action-list.items" role="none" data-view-component="true" class="ActionListItem"> <a tabindex="-1" id="item-8406df03-bdfa-43ba-8131-f57ca1453dd5" href="/python/peps/pulse" role="menuitem" data-view-component="true" class="ActionListContent ActionListContent--visual16"> <span class="ActionListItem-visual ActionListItem-visual--leading"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path> </svg> </span> <span data-view-component="true" class="ActionListItem-label"> Insights </span> </a> </li> </ul> </div></action-list> </div> </div></anchored-position> </focus-group> </action-menu></div> </nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <react-app app-name="react-code-view" initial-path="/python/peps/blob/main/peps/pep-0622.rst" style="display: block; min-height: calc(100vh - 64px);" data-attempted-ssr="true" data-ssr="true" data-lazy="false" data-alternate="false" data-data-router-enabled="false" > <script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"fileTree":{"peps":{"items":[{"name":"api","path":"peps/api","contentType":"directory"},{"name":"pep-0001","path":"peps/pep-0001","contentType":"directory"},{"name":"pep-0012","path":"peps/pep-0012","contentType":"directory"},{"name":"pep-0418","path":"peps/pep-0418","contentType":"directory"},{"name":"pep-0426","path":"peps/pep-0426","contentType":"directory"},{"name":"pep-0433","path":"peps/pep-0433","contentType":"directory"},{"name":"pep-0446","path":"peps/pep-0446","contentType":"directory"},{"name":"pep-0465","path":"peps/pep-0465","contentType":"directory"},{"name":"pep-0505","path":"peps/pep-0505","contentType":"directory"},{"name":"pep-0532","path":"peps/pep-0532","contentType":"directory"},{"name":"pep-0605","path":"peps/pep-0605","contentType":"directory"},{"name":"pep-0639","path":"peps/pep-0639","contentType":"directory"},{"name":"pep-0662","path":"peps/pep-0662","contentType":"directory"},{"name":"pep-0739","path":"peps/pep-0739","contentType":"directory"},{"name":"pep-0777","path":"peps/pep-0777","contentType":"directory"},{"name":"conf.py","path":"peps/conf.py","contentType":"file"},{"name":"contents.rst","path":"peps/contents.rst","contentType":"file"},{"name":"pep-0001.rst","path":"peps/pep-0001.rst","contentType":"file"},{"name":"pep-0002.rst","path":"peps/pep-0002.rst","contentType":"file"},{"name":"pep-0003.rst","path":"peps/pep-0003.rst","contentType":"file"},{"name":"pep-0004.rst","path":"peps/pep-0004.rst","contentType":"file"},{"name":"pep-0005.rst","path":"peps/pep-0005.rst","contentType":"file"},{"name":"pep-0006.rst","path":"peps/pep-0006.rst","contentType":"file"},{"name":"pep-0007.rst","path":"peps/pep-0007.rst","contentType":"file"},{"name":"pep-0008.rst","path":"peps/pep-0008.rst","contentType":"file"},{"name":"pep-0009.rst","path":"peps/pep-0009.rst","contentType":"file"},{"name":"pep-0010.rst","path":"peps/pep-0010.rst","contentType":"file"},{"name":"pep-0011.rst","path":"peps/pep-0011.rst","contentType":"file"},{"name":"pep-0012.rst","path":"peps/pep-0012.rst","contentType":"file"},{"name":"pep-0013.rst","path":"peps/pep-0013.rst","contentType":"file"},{"name":"pep-0020.rst","path":"peps/pep-0020.rst","contentType":"file"},{"name":"pep-0042.rst","path":"peps/pep-0042.rst","contentType":"file"},{"name":"pep-0100.rst","path":"peps/pep-0100.rst","contentType":"file"},{"name":"pep-0101.rst","path":"peps/pep-0101.rst","contentType":"file"},{"name":"pep-0102.rst","path":"peps/pep-0102.rst","contentType":"file"},{"name":"pep-0103.rst","path":"peps/pep-0103.rst","contentType":"file"},{"name":"pep-0160.rst","path":"peps/pep-0160.rst","contentType":"file"},{"name":"pep-0200.rst","path":"peps/pep-0200.rst","contentType":"file"},{"name":"pep-0201.rst","path":"peps/pep-0201.rst","contentType":"file"},{"name":"pep-0202.rst","path":"peps/pep-0202.rst","contentType":"file"},{"name":"pep-0203.rst","path":"peps/pep-0203.rst","contentType":"file"},{"name":"pep-0204.rst","path":"peps/pep-0204.rst","contentType":"file"},{"name":"pep-0205.rst","path":"peps/pep-0205.rst","contentType":"file"},{"name":"pep-0206.rst","path":"peps/pep-0206.rst","contentType":"file"},{"name":"pep-0207.rst","path":"peps/pep-0207.rst","contentType":"file"},{"name":"pep-0208.rst","path":"peps/pep-0208.rst","contentType":"file"},{"name":"pep-0209.rst","path":"peps/pep-0209.rst","contentType":"file"},{"name":"pep-0210.rst","path":"peps/pep-0210.rst","contentType":"file"},{"name":"pep-0211.rst","path":"peps/pep-0211.rst","contentType":"file"},{"name":"pep-0212.rst","path":"peps/pep-0212.rst","contentType":"file"},{"name":"pep-0213.rst","path":"peps/pep-0213.rst","contentType":"file"},{"name":"pep-0214.rst","path":"peps/pep-0214.rst","contentType":"file"},{"name":"pep-0215.rst","path":"peps/pep-0215.rst","contentType":"file"},{"name":"pep-0216.rst","path":"peps/pep-0216.rst","contentType":"file"},{"name":"pep-0217.rst","path":"peps/pep-0217.rst","contentType":"file"},{"name":"pep-0218.rst","path":"peps/pep-0218.rst","contentType":"file"},{"name":"pep-0219.rst","path":"peps/pep-0219.rst","contentType":"file"},{"name":"pep-0220.rst","path":"peps/pep-0220.rst","contentType":"file"},{"name":"pep-0221.rst","path":"peps/pep-0221.rst","contentType":"file"},{"name":"pep-0222.rst","path":"peps/pep-0222.rst","contentType":"file"},{"name":"pep-0223.rst","path":"peps/pep-0223.rst","contentType":"file"},{"name":"pep-0224.rst","path":"peps/pep-0224.rst","contentType":"file"},{"name":"pep-0225.rst","path":"peps/pep-0225.rst","contentType":"file"},{"name":"pep-0226.rst","path":"peps/pep-0226.rst","contentType":"file"},{"name":"pep-0227.rst","path":"peps/pep-0227.rst","contentType":"file"},{"name":"pep-0228.rst","path":"peps/pep-0228.rst","contentType":"file"},{"name":"pep-0229.rst","path":"peps/pep-0229.rst","contentType":"file"},{"name":"pep-0230.rst","path":"peps/pep-0230.rst","contentType":"file"},{"name":"pep-0231.rst","path":"peps/pep-0231.rst","contentType":"file"},{"name":"pep-0232.rst","path":"peps/pep-0232.rst","contentType":"file"},{"name":"pep-0233.rst","path":"peps/pep-0233.rst","contentType":"file"},{"name":"pep-0234.rst","path":"peps/pep-0234.rst","contentType":"file"},{"name":"pep-0235.rst","path":"peps/pep-0235.rst","contentType":"file"},{"name":"pep-0236.rst","path":"peps/pep-0236.rst","contentType":"file"},{"name":"pep-0237.rst","path":"peps/pep-0237.rst","contentType":"file"},{"name":"pep-0238.rst","path":"peps/pep-0238.rst","contentType":"file"},{"name":"pep-0239.rst","path":"peps/pep-0239.rst","contentType":"file"},{"name":"pep-0240.rst","path":"peps/pep-0240.rst","contentType":"file"},{"name":"pep-0241.rst","path":"peps/pep-0241.rst","contentType":"file"},{"name":"pep-0242.rst","path":"peps/pep-0242.rst","contentType":"file"},{"name":"pep-0243.rst","path":"peps/pep-0243.rst","contentType":"file"},{"name":"pep-0244.rst","path":"peps/pep-0244.rst","contentType":"file"},{"name":"pep-0245.rst","path":"peps/pep-0245.rst","contentType":"file"},{"name":"pep-0246.rst","path":"peps/pep-0246.rst","contentType":"file"},{"name":"pep-0247.rst","path":"peps/pep-0247.rst","contentType":"file"},{"name":"pep-0248.rst","path":"peps/pep-0248.rst","contentType":"file"},{"name":"pep-0249.rst","path":"peps/pep-0249.rst","contentType":"file"},{"name":"pep-0250.rst","path":"peps/pep-0250.rst","contentType":"file"},{"name":"pep-0251.rst","path":"peps/pep-0251.rst","contentType":"file"},{"name":"pep-0252.rst","path":"peps/pep-0252.rst","contentType":"file"},{"name":"pep-0253.rst","path":"peps/pep-0253.rst","contentType":"file"},{"name":"pep-0254.rst","path":"peps/pep-0254.rst","contentType":"file"},{"name":"pep-0255.rst","path":"peps/pep-0255.rst","contentType":"file"},{"name":"pep-0256.rst","path":"peps/pep-0256.rst","contentType":"file"},{"name":"pep-0257.rst","path":"peps/pep-0257.rst","contentType":"file"},{"name":"pep-0258.rst","path":"peps/pep-0258.rst","contentType":"file"},{"name":"pep-0259.rst","path":"peps/pep-0259.rst","contentType":"file"},{"name":"pep-0260.rst","path":"peps/pep-0260.rst","contentType":"file"},{"name":"pep-0261.rst","path":"peps/pep-0261.rst","contentType":"file"},{"name":"pep-0262.rst","path":"peps/pep-0262.rst","contentType":"file"},{"name":"pep-0263.rst","path":"peps/pep-0263.rst","contentType":"file"},{"name":"pep-0264.rst","path":"peps/pep-0264.rst","contentType":"file"},{"name":"pep-0265.rst","path":"peps/pep-0265.rst","contentType":"file"},{"name":"pep-0266.rst","path":"peps/pep-0266.rst","contentType":"file"},{"name":"pep-0267.rst","path":"peps/pep-0267.rst","contentType":"file"},{"name":"pep-0268.rst","path":"peps/pep-0268.rst","contentType":"file"},{"name":"pep-0269.rst","path":"peps/pep-0269.rst","contentType":"file"},{"name":"pep-0270.rst","path":"peps/pep-0270.rst","contentType":"file"},{"name":"pep-0271.rst","path":"peps/pep-0271.rst","contentType":"file"},{"name":"pep-0272.rst","path":"peps/pep-0272.rst","contentType":"file"},{"name":"pep-0273.rst","path":"peps/pep-0273.rst","contentType":"file"},{"name":"pep-0274.rst","path":"peps/pep-0274.rst","contentType":"file"},{"name":"pep-0275.rst","path":"peps/pep-0275.rst","contentType":"file"},{"name":"pep-0276.rst","path":"peps/pep-0276.rst","contentType":"file"},{"name":"pep-0277.rst","path":"peps/pep-0277.rst","contentType":"file"},{"name":"pep-0278.rst","path":"peps/pep-0278.rst","contentType":"file"},{"name":"pep-0279.rst","path":"peps/pep-0279.rst","contentType":"file"},{"name":"pep-0280.rst","path":"peps/pep-0280.rst","contentType":"file"},{"name":"pep-0281.rst","path":"peps/pep-0281.rst","contentType":"file"},{"name":"pep-0282.rst","path":"peps/pep-0282.rst","contentType":"file"},{"name":"pep-0283.rst","path":"peps/pep-0283.rst","contentType":"file"},{"name":"pep-0284.rst","path":"peps/pep-0284.rst","contentType":"file"},{"name":"pep-0285.rst","path":"peps/pep-0285.rst","contentType":"file"},{"name":"pep-0286.rst","path":"peps/pep-0286.rst","contentType":"file"},{"name":"pep-0287.rst","path":"peps/pep-0287.rst","contentType":"file"},{"name":"pep-0288.rst","path":"peps/pep-0288.rst","contentType":"file"},{"name":"pep-0289.rst","path":"peps/pep-0289.rst","contentType":"file"},{"name":"pep-0290.rst","path":"peps/pep-0290.rst","contentType":"file"},{"name":"pep-0291.rst","path":"peps/pep-0291.rst","contentType":"file"},{"name":"pep-0292.rst","path":"peps/pep-0292.rst","contentType":"file"},{"name":"pep-0293.rst","path":"peps/pep-0293.rst","contentType":"file"},{"name":"pep-0294.rst","path":"peps/pep-0294.rst","contentType":"file"},{"name":"pep-0295.rst","path":"peps/pep-0295.rst","contentType":"file"},{"name":"pep-0296.rst","path":"peps/pep-0296.rst","contentType":"file"},{"name":"pep-0297.rst","path":"peps/pep-0297.rst","contentType":"file"},{"name":"pep-0298.rst","path":"peps/pep-0298.rst","contentType":"file"},{"name":"pep-0299.rst","path":"peps/pep-0299.rst","contentType":"file"},{"name":"pep-0301.rst","path":"peps/pep-0301.rst","contentType":"file"},{"name":"pep-0302.rst","path":"peps/pep-0302.rst","contentType":"file"},{"name":"pep-0303.rst","path":"peps/pep-0303.rst","contentType":"file"},{"name":"pep-0304.rst","path":"peps/pep-0304.rst","contentType":"file"},{"name":"pep-0305.rst","path":"peps/pep-0305.rst","contentType":"file"},{"name":"pep-0306.rst","path":"peps/pep-0306.rst","contentType":"file"},{"name":"pep-0307.rst","path":"peps/pep-0307.rst","contentType":"file"},{"name":"pep-0308.rst","path":"peps/pep-0308.rst","contentType":"file"},{"name":"pep-0309.rst","path":"peps/pep-0309.rst","contentType":"file"},{"name":"pep-0310.rst","path":"peps/pep-0310.rst","contentType":"file"},{"name":"pep-0311.rst","path":"peps/pep-0311.rst","contentType":"file"},{"name":"pep-0312.rst","path":"peps/pep-0312.rst","contentType":"file"},{"name":"pep-0313.rst","path":"peps/pep-0313.rst","contentType":"file"},{"name":"pep-0314.rst","path":"peps/pep-0314.rst","contentType":"file"},{"name":"pep-0315.rst","path":"peps/pep-0315.rst","contentType":"file"},{"name":"pep-0316.rst","path":"peps/pep-0316.rst","contentType":"file"},{"name":"pep-0317.rst","path":"peps/pep-0317.rst","contentType":"file"},{"name":"pep-0318.rst","path":"peps/pep-0318.rst","contentType":"file"},{"name":"pep-0319.rst","path":"peps/pep-0319.rst","contentType":"file"},{"name":"pep-0320.rst","path":"peps/pep-0320.rst","contentType":"file"},{"name":"pep-0321.rst","path":"peps/pep-0321.rst","contentType":"file"},{"name":"pep-0322.rst","path":"peps/pep-0322.rst","contentType":"file"},{"name":"pep-0323.rst","path":"peps/pep-0323.rst","contentType":"file"},{"name":"pep-0324.rst","path":"peps/pep-0324.rst","contentType":"file"},{"name":"pep-0325.rst","path":"peps/pep-0325.rst","contentType":"file"},{"name":"pep-0326.rst","path":"peps/pep-0326.rst","contentType":"file"},{"name":"pep-0327.rst","path":"peps/pep-0327.rst","contentType":"file"},{"name":"pep-0328.rst","path":"peps/pep-0328.rst","contentType":"file"},{"name":"pep-0329.rst","path":"peps/pep-0329.rst","contentType":"file"},{"name":"pep-0330.rst","path":"peps/pep-0330.rst","contentType":"file"},{"name":"pep-0331.rst","path":"peps/pep-0331.rst","contentType":"file"},{"name":"pep-0332.rst","path":"peps/pep-0332.rst","contentType":"file"},{"name":"pep-0333.rst","path":"peps/pep-0333.rst","contentType":"file"},{"name":"pep-0334.rst","path":"peps/pep-0334.rst","contentType":"file"},{"name":"pep-0335.rst","path":"peps/pep-0335.rst","contentType":"file"},{"name":"pep-0336.rst","path":"peps/pep-0336.rst","contentType":"file"},{"name":"pep-0337.rst","path":"peps/pep-0337.rst","contentType":"file"},{"name":"pep-0338.rst","path":"peps/pep-0338.rst","contentType":"file"},{"name":"pep-0339.rst","path":"peps/pep-0339.rst","contentType":"file"},{"name":"pep-0340.rst","path":"peps/pep-0340.rst","contentType":"file"},{"name":"pep-0341.rst","path":"peps/pep-0341.rst","contentType":"file"},{"name":"pep-0342.rst","path":"peps/pep-0342.rst","contentType":"file"},{"name":"pep-0343.rst","path":"peps/pep-0343.rst","contentType":"file"},{"name":"pep-0344.rst","path":"peps/pep-0344.rst","contentType":"file"},{"name":"pep-0345.rst","path":"peps/pep-0345.rst","contentType":"file"},{"name":"pep-0346.rst","path":"peps/pep-0346.rst","contentType":"file"},{"name":"pep-0347.rst","path":"peps/pep-0347.rst","contentType":"file"},{"name":"pep-0348.rst","path":"peps/pep-0348.rst","contentType":"file"},{"name":"pep-0349.rst","path":"peps/pep-0349.rst","contentType":"file"},{"name":"pep-0350.rst","path":"peps/pep-0350.rst","contentType":"file"},{"name":"pep-0351.rst","path":"peps/pep-0351.rst","contentType":"file"},{"name":"pep-0352.rst","path":"peps/pep-0352.rst","contentType":"file"},{"name":"pep-0353.rst","path":"peps/pep-0353.rst","contentType":"file"},{"name":"pep-0354.rst","path":"peps/pep-0354.rst","contentType":"file"},{"name":"pep-0355.rst","path":"peps/pep-0355.rst","contentType":"file"},{"name":"pep-0356.rst","path":"peps/pep-0356.rst","contentType":"file"},{"name":"pep-0357.rst","path":"peps/pep-0357.rst","contentType":"file"},{"name":"pep-0358.rst","path":"peps/pep-0358.rst","contentType":"file"},{"name":"pep-0359.rst","path":"peps/pep-0359.rst","contentType":"file"},{"name":"pep-0360.rst","path":"peps/pep-0360.rst","contentType":"file"},{"name":"pep-0361.rst","path":"peps/pep-0361.rst","contentType":"file"},{"name":"pep-0362.rst","path":"peps/pep-0362.rst","contentType":"file"},{"name":"pep-0363.rst","path":"peps/pep-0363.rst","contentType":"file"},{"name":"pep-0364.rst","path":"peps/pep-0364.rst","contentType":"file"},{"name":"pep-0365.rst","path":"peps/pep-0365.rst","contentType":"file"},{"name":"pep-0366.rst","path":"peps/pep-0366.rst","contentType":"file"},{"name":"pep-0367.rst","path":"peps/pep-0367.rst","contentType":"file"},{"name":"pep-0368.rst","path":"peps/pep-0368.rst","contentType":"file"},{"name":"pep-0369.rst","path":"peps/pep-0369.rst","contentType":"file"},{"name":"pep-0370.rst","path":"peps/pep-0370.rst","contentType":"file"},{"name":"pep-0371.rst","path":"peps/pep-0371.rst","contentType":"file"},{"name":"pep-0372.rst","path":"peps/pep-0372.rst","contentType":"file"},{"name":"pep-0373.rst","path":"peps/pep-0373.rst","contentType":"file"},{"name":"pep-0374.rst","path":"peps/pep-0374.rst","contentType":"file"},{"name":"pep-0375.rst","path":"peps/pep-0375.rst","contentType":"file"},{"name":"pep-0376.rst","path":"peps/pep-0376.rst","contentType":"file"},{"name":"pep-0377.rst","path":"peps/pep-0377.rst","contentType":"file"},{"name":"pep-0378.rst","path":"peps/pep-0378.rst","contentType":"file"},{"name":"pep-0379.rst","path":"peps/pep-0379.rst","contentType":"file"},{"name":"pep-0380.rst","path":"peps/pep-0380.rst","contentType":"file"},{"name":"pep-0381.rst","path":"peps/pep-0381.rst","contentType":"file"},{"name":"pep-0382.rst","path":"peps/pep-0382.rst","contentType":"file"},{"name":"pep-0383.rst","path":"peps/pep-0383.rst","contentType":"file"},{"name":"pep-0384.rst","path":"peps/pep-0384.rst","contentType":"file"},{"name":"pep-0385.rst","path":"peps/pep-0385.rst","contentType":"file"},{"name":"pep-0386.rst","path":"peps/pep-0386.rst","contentType":"file"},{"name":"pep-0387.rst","path":"peps/pep-0387.rst","contentType":"file"},{"name":"pep-0389.rst","path":"peps/pep-0389.rst","contentType":"file"},{"name":"pep-0390.rst","path":"peps/pep-0390.rst","contentType":"file"},{"name":"pep-0391.rst","path":"peps/pep-0391.rst","contentType":"file"},{"name":"pep-0392.rst","path":"peps/pep-0392.rst","contentType":"file"},{"name":"pep-0393.rst","path":"peps/pep-0393.rst","contentType":"file"},{"name":"pep-0394.rst","path":"peps/pep-0394.rst","contentType":"file"},{"name":"pep-0395.rst","path":"peps/pep-0395.rst","contentType":"file"},{"name":"pep-0396.rst","path":"peps/pep-0396.rst","contentType":"file"},{"name":"pep-0397.rst","path":"peps/pep-0397.rst","contentType":"file"},{"name":"pep-0398.rst","path":"peps/pep-0398.rst","contentType":"file"},{"name":"pep-0399.rst","path":"peps/pep-0399.rst","contentType":"file"},{"name":"pep-0400.rst","path":"peps/pep-0400.rst","contentType":"file"},{"name":"pep-0401.rst","path":"peps/pep-0401.rst","contentType":"file"},{"name":"pep-0402.rst","path":"peps/pep-0402.rst","contentType":"file"},{"name":"pep-0403.rst","path":"peps/pep-0403.rst","contentType":"file"},{"name":"pep-0404.rst","path":"peps/pep-0404.rst","contentType":"file"},{"name":"pep-0405.rst","path":"peps/pep-0405.rst","contentType":"file"},{"name":"pep-0406.rst","path":"peps/pep-0406.rst","contentType":"file"},{"name":"pep-0407.rst","path":"peps/pep-0407.rst","contentType":"file"},{"name":"pep-0408.rst","path":"peps/pep-0408.rst","contentType":"file"},{"name":"pep-0409.rst","path":"peps/pep-0409.rst","contentType":"file"},{"name":"pep-0410.rst","path":"peps/pep-0410.rst","contentType":"file"},{"name":"pep-0411.rst","path":"peps/pep-0411.rst","contentType":"file"},{"name":"pep-0412.rst","path":"peps/pep-0412.rst","contentType":"file"},{"name":"pep-0413.rst","path":"peps/pep-0413.rst","contentType":"file"},{"name":"pep-0414.rst","path":"peps/pep-0414.rst","contentType":"file"},{"name":"pep-0415.rst","path":"peps/pep-0415.rst","contentType":"file"},{"name":"pep-0416.rst","path":"peps/pep-0416.rst","contentType":"file"},{"name":"pep-0417.rst","path":"peps/pep-0417.rst","contentType":"file"},{"name":"pep-0418.rst","path":"peps/pep-0418.rst","contentType":"file"},{"name":"pep-0419.rst","path":"peps/pep-0419.rst","contentType":"file"},{"name":"pep-0420.rst","path":"peps/pep-0420.rst","contentType":"file"},{"name":"pep-0421.rst","path":"peps/pep-0421.rst","contentType":"file"},{"name":"pep-0422.rst","path":"peps/pep-0422.rst","contentType":"file"},{"name":"pep-0423.rst","path":"peps/pep-0423.rst","contentType":"file"},{"name":"pep-0424.rst","path":"peps/pep-0424.rst","contentType":"file"},{"name":"pep-0425.rst","path":"peps/pep-0425.rst","contentType":"file"},{"name":"pep-0426.rst","path":"peps/pep-0426.rst","contentType":"file"},{"name":"pep-0427.rst","path":"peps/pep-0427.rst","contentType":"file"},{"name":"pep-0428.rst","path":"peps/pep-0428.rst","contentType":"file"},{"name":"pep-0429.rst","path":"peps/pep-0429.rst","contentType":"file"},{"name":"pep-0430.rst","path":"peps/pep-0430.rst","contentType":"file"},{"name":"pep-0431.rst","path":"peps/pep-0431.rst","contentType":"file"},{"name":"pep-0432.rst","path":"peps/pep-0432.rst","contentType":"file"},{"name":"pep-0433.rst","path":"peps/pep-0433.rst","contentType":"file"},{"name":"pep-0434.rst","path":"peps/pep-0434.rst","contentType":"file"},{"name":"pep-0435.rst","path":"peps/pep-0435.rst","contentType":"file"},{"name":"pep-0436.rst","path":"peps/pep-0436.rst","contentType":"file"},{"name":"pep-0437.rst","path":"peps/pep-0437.rst","contentType":"file"},{"name":"pep-0438.rst","path":"peps/pep-0438.rst","contentType":"file"},{"name":"pep-0439.rst","path":"peps/pep-0439.rst","contentType":"file"},{"name":"pep-0440.rst","path":"peps/pep-0440.rst","contentType":"file"},{"name":"pep-0441.rst","path":"peps/pep-0441.rst","contentType":"file"},{"name":"pep-0442.rst","path":"peps/pep-0442.rst","contentType":"file"},{"name":"pep-0443.rst","path":"peps/pep-0443.rst","contentType":"file"},{"name":"pep-0444.rst","path":"peps/pep-0444.rst","contentType":"file"},{"name":"pep-0445.rst","path":"peps/pep-0445.rst","contentType":"file"},{"name":"pep-0446.rst","path":"peps/pep-0446.rst","contentType":"file"},{"name":"pep-0447.rst","path":"peps/pep-0447.rst","contentType":"file"},{"name":"pep-0448.rst","path":"peps/pep-0448.rst","contentType":"file"},{"name":"pep-0449.rst","path":"peps/pep-0449.rst","contentType":"file"},{"name":"pep-0450.rst","path":"peps/pep-0450.rst","contentType":"file"},{"name":"pep-0451.rst","path":"peps/pep-0451.rst","contentType":"file"},{"name":"pep-0452.rst","path":"peps/pep-0452.rst","contentType":"file"},{"name":"pep-0453.rst","path":"peps/pep-0453.rst","contentType":"file"},{"name":"pep-0454.rst","path":"peps/pep-0454.rst","contentType":"file"},{"name":"pep-0455.rst","path":"peps/pep-0455.rst","contentType":"file"},{"name":"pep-0456.rst","path":"peps/pep-0456.rst","contentType":"file"},{"name":"pep-0457.rst","path":"peps/pep-0457.rst","contentType":"file"},{"name":"pep-0458-1.png","path":"peps/pep-0458-1.png","contentType":"file"},{"name":"pep-0458.rst","path":"peps/pep-0458.rst","contentType":"file"},{"name":"pep-0459.rst","path":"peps/pep-0459.rst","contentType":"file"},{"name":"pep-0460.rst","path":"peps/pep-0460.rst","contentType":"file"},{"name":"pep-0461.rst","path":"peps/pep-0461.rst","contentType":"file"},{"name":"pep-0462.rst","path":"peps/pep-0462.rst","contentType":"file"},{"name":"pep-0463.rst","path":"peps/pep-0463.rst","contentType":"file"},{"name":"pep-0464.rst","path":"peps/pep-0464.rst","contentType":"file"},{"name":"pep-0465.rst","path":"peps/pep-0465.rst","contentType":"file"},{"name":"pep-0466.rst","path":"peps/pep-0466.rst","contentType":"file"},{"name":"pep-0467.rst","path":"peps/pep-0467.rst","contentType":"file"},{"name":"pep-0468.rst","path":"peps/pep-0468.rst","contentType":"file"},{"name":"pep-0469.rst","path":"peps/pep-0469.rst","contentType":"file"},{"name":"pep-0470.rst","path":"peps/pep-0470.rst","contentType":"file"},{"name":"pep-0471.rst","path":"peps/pep-0471.rst","contentType":"file"},{"name":"pep-0472.rst","path":"peps/pep-0472.rst","contentType":"file"},{"name":"pep-0473.rst","path":"peps/pep-0473.rst","contentType":"file"},{"name":"pep-0474.rst","path":"peps/pep-0474.rst","contentType":"file"},{"name":"pep-0475.rst","path":"peps/pep-0475.rst","contentType":"file"},{"name":"pep-0476.rst","path":"peps/pep-0476.rst","contentType":"file"},{"name":"pep-0477.rst","path":"peps/pep-0477.rst","contentType":"file"},{"name":"pep-0478.rst","path":"peps/pep-0478.rst","contentType":"file"},{"name":"pep-0479.rst","path":"peps/pep-0479.rst","contentType":"file"},{"name":"pep-0480-1.png","path":"peps/pep-0480-1.png","contentType":"file"},{"name":"pep-0480.rst","path":"peps/pep-0480.rst","contentType":"file"},{"name":"pep-0481.rst","path":"peps/pep-0481.rst","contentType":"file"},{"name":"pep-0482.rst","path":"peps/pep-0482.rst","contentType":"file"},{"name":"pep-0483.rst","path":"peps/pep-0483.rst","contentType":"file"},{"name":"pep-0484.rst","path":"peps/pep-0484.rst","contentType":"file"},{"name":"pep-0485.rst","path":"peps/pep-0485.rst","contentType":"file"},{"name":"pep-0486.rst","path":"peps/pep-0486.rst","contentType":"file"},{"name":"pep-0487.rst","path":"peps/pep-0487.rst","contentType":"file"},{"name":"pep-0488.rst","path":"peps/pep-0488.rst","contentType":"file"},{"name":"pep-0489.rst","path":"peps/pep-0489.rst","contentType":"file"},{"name":"pep-0490.rst","path":"peps/pep-0490.rst","contentType":"file"},{"name":"pep-0491.rst","path":"peps/pep-0491.rst","contentType":"file"},{"name":"pep-0492.rst","path":"peps/pep-0492.rst","contentType":"file"},{"name":"pep-0493.rst","path":"peps/pep-0493.rst","contentType":"file"},{"name":"pep-0494.rst","path":"peps/pep-0494.rst","contentType":"file"},{"name":"pep-0495-daylightsavings.png","path":"peps/pep-0495-daylightsavings.png","contentType":"file"},{"name":"pep-0495-fold.svg","path":"peps/pep-0495-fold.svg","contentType":"file"},{"name":"pep-0495-gap.svg","path":"peps/pep-0495-gap.svg","contentType":"file"},{"name":"pep-0495.rst","path":"peps/pep-0495.rst","contentType":"file"},{"name":"pep-0496.rst","path":"peps/pep-0496.rst","contentType":"file"},{"name":"pep-0497.rst","path":"peps/pep-0497.rst","contentType":"file"},{"name":"pep-0498.rst","path":"peps/pep-0498.rst","contentType":"file"},{"name":"pep-0499.rst","path":"peps/pep-0499.rst","contentType":"file"},{"name":"pep-0500.rst","path":"peps/pep-0500.rst","contentType":"file"},{"name":"pep-0501.rst","path":"peps/pep-0501.rst","contentType":"file"},{"name":"pep-0502.rst","path":"peps/pep-0502.rst","contentType":"file"},{"name":"pep-0503.rst","path":"peps/pep-0503.rst","contentType":"file"},{"name":"pep-0504.rst","path":"peps/pep-0504.rst","contentType":"file"},{"name":"pep-0505.rst","path":"peps/pep-0505.rst","contentType":"file"},{"name":"pep-0506.rst","path":"peps/pep-0506.rst","contentType":"file"},{"name":"pep-0507.rst","path":"peps/pep-0507.rst","contentType":"file"},{"name":"pep-0508.rst","path":"peps/pep-0508.rst","contentType":"file"},{"name":"pep-0509.rst","path":"peps/pep-0509.rst","contentType":"file"},{"name":"pep-0510.rst","path":"peps/pep-0510.rst","contentType":"file"},{"name":"pep-0511.rst","path":"peps/pep-0511.rst","contentType":"file"},{"name":"pep-0512.rst","path":"peps/pep-0512.rst","contentType":"file"},{"name":"pep-0513.rst","path":"peps/pep-0513.rst","contentType":"file"},{"name":"pep-0514.rst","path":"peps/pep-0514.rst","contentType":"file"},{"name":"pep-0515.rst","path":"peps/pep-0515.rst","contentType":"file"},{"name":"pep-0516.rst","path":"peps/pep-0516.rst","contentType":"file"},{"name":"pep-0517.rst","path":"peps/pep-0517.rst","contentType":"file"},{"name":"pep-0518.rst","path":"peps/pep-0518.rst","contentType":"file"},{"name":"pep-0519.rst","path":"peps/pep-0519.rst","contentType":"file"},{"name":"pep-0520.rst","path":"peps/pep-0520.rst","contentType":"file"},{"name":"pep-0521.rst","path":"peps/pep-0521.rst","contentType":"file"},{"name":"pep-0522.rst","path":"peps/pep-0522.rst","contentType":"file"},{"name":"pep-0523.rst","path":"peps/pep-0523.rst","contentType":"file"},{"name":"pep-0524.rst","path":"peps/pep-0524.rst","contentType":"file"},{"name":"pep-0525-1.png","path":"peps/pep-0525-1.png","contentType":"file"},{"name":"pep-0525.rst","path":"peps/pep-0525.rst","contentType":"file"},{"name":"pep-0526.rst","path":"peps/pep-0526.rst","contentType":"file"},{"name":"pep-0527.rst","path":"peps/pep-0527.rst","contentType":"file"},{"name":"pep-0528.rst","path":"peps/pep-0528.rst","contentType":"file"},{"name":"pep-0529.rst","path":"peps/pep-0529.rst","contentType":"file"},{"name":"pep-0530.rst","path":"peps/pep-0530.rst","contentType":"file"},{"name":"pep-0531.rst","path":"peps/pep-0531.rst","contentType":"file"},{"name":"pep-0532.rst","path":"peps/pep-0532.rst","contentType":"file"},{"name":"pep-0533.rst","path":"peps/pep-0533.rst","contentType":"file"},{"name":"pep-0534.rst","path":"peps/pep-0534.rst","contentType":"file"},{"name":"pep-0535.rst","path":"peps/pep-0535.rst","contentType":"file"},{"name":"pep-0536.rst","path":"peps/pep-0536.rst","contentType":"file"},{"name":"pep-0537.rst","path":"peps/pep-0537.rst","contentType":"file"},{"name":"pep-0538.rst","path":"peps/pep-0538.rst","contentType":"file"},{"name":"pep-0539.rst","path":"peps/pep-0539.rst","contentType":"file"},{"name":"pep-0540.rst","path":"peps/pep-0540.rst","contentType":"file"},{"name":"pep-0541.rst","path":"peps/pep-0541.rst","contentType":"file"},{"name":"pep-0542.rst","path":"peps/pep-0542.rst","contentType":"file"},{"name":"pep-0543.rst","path":"peps/pep-0543.rst","contentType":"file"},{"name":"pep-0544.rst","path":"peps/pep-0544.rst","contentType":"file"},{"name":"pep-0545.rst","path":"peps/pep-0545.rst","contentType":"file"},{"name":"pep-0546.rst","path":"peps/pep-0546.rst","contentType":"file"},{"name":"pep-0547.rst","path":"peps/pep-0547.rst","contentType":"file"},{"name":"pep-0548.rst","path":"peps/pep-0548.rst","contentType":"file"},{"name":"pep-0549.rst","path":"peps/pep-0549.rst","contentType":"file"},{"name":"pep-0550-hamt_vs_dict-v2.png","path":"peps/pep-0550-hamt_vs_dict-v2.png","contentType":"file"},{"name":"pep-0550-hamt_vs_dict.png","path":"peps/pep-0550-hamt_vs_dict.png","contentType":"file"},{"name":"pep-0550-lookup_hamt.png","path":"peps/pep-0550-lookup_hamt.png","contentType":"file"},{"name":"pep-0550.rst","path":"peps/pep-0550.rst","contentType":"file"},{"name":"pep-0551.rst","path":"peps/pep-0551.rst","contentType":"file"},{"name":"pep-0552.rst","path":"peps/pep-0552.rst","contentType":"file"},{"name":"pep-0553.rst","path":"peps/pep-0553.rst","contentType":"file"},{"name":"pep-0554.rst","path":"peps/pep-0554.rst","contentType":"file"},{"name":"pep-0555.rst","path":"peps/pep-0555.rst","contentType":"file"},{"name":"pep-0556.rst","path":"peps/pep-0556.rst","contentType":"file"},{"name":"pep-0557.rst","path":"peps/pep-0557.rst","contentType":"file"},{"name":"pep-0558.rst","path":"peps/pep-0558.rst","contentType":"file"},{"name":"pep-0559.rst","path":"peps/pep-0559.rst","contentType":"file"},{"name":"pep-0560.rst","path":"peps/pep-0560.rst","contentType":"file"},{"name":"pep-0561.rst","path":"peps/pep-0561.rst","contentType":"file"},{"name":"pep-0562.rst","path":"peps/pep-0562.rst","contentType":"file"},{"name":"pep-0563.rst","path":"peps/pep-0563.rst","contentType":"file"},{"name":"pep-0564.rst","path":"peps/pep-0564.rst","contentType":"file"},{"name":"pep-0565.rst","path":"peps/pep-0565.rst","contentType":"file"},{"name":"pep-0566.rst","path":"peps/pep-0566.rst","contentType":"file"},{"name":"pep-0567.rst","path":"peps/pep-0567.rst","contentType":"file"},{"name":"pep-0568.rst","path":"peps/pep-0568.rst","contentType":"file"},{"name":"pep-0569.rst","path":"peps/pep-0569.rst","contentType":"file"},{"name":"pep-0570.rst","path":"peps/pep-0570.rst","contentType":"file"},{"name":"pep-0571.rst","path":"peps/pep-0571.rst","contentType":"file"},{"name":"pep-0572.rst","path":"peps/pep-0572.rst","contentType":"file"},{"name":"pep-0573.rst","path":"peps/pep-0573.rst","contentType":"file"},{"name":"pep-0574.rst","path":"peps/pep-0574.rst","contentType":"file"},{"name":"pep-0575.rst","path":"peps/pep-0575.rst","contentType":"file"},{"name":"pep-0576.rst","path":"peps/pep-0576.rst","contentType":"file"},{"name":"pep-0577.rst","path":"peps/pep-0577.rst","contentType":"file"},{"name":"pep-0578.rst","path":"peps/pep-0578.rst","contentType":"file"},{"name":"pep-0579.rst","path":"peps/pep-0579.rst","contentType":"file"},{"name":"pep-0580.rst","path":"peps/pep-0580.rst","contentType":"file"},{"name":"pep-0581.rst","path":"peps/pep-0581.rst","contentType":"file"},{"name":"pep-0582.rst","path":"peps/pep-0582.rst","contentType":"file"},{"name":"pep-0583.rst","path":"peps/pep-0583.rst","contentType":"file"},{"name":"pep-0584.rst","path":"peps/pep-0584.rst","contentType":"file"},{"name":"pep-0585.rst","path":"peps/pep-0585.rst","contentType":"file"},{"name":"pep-0586.rst","path":"peps/pep-0586.rst","contentType":"file"},{"name":"pep-0587.rst","path":"peps/pep-0587.rst","contentType":"file"},{"name":"pep-0588.rst","path":"peps/pep-0588.rst","contentType":"file"},{"name":"pep-0589.rst","path":"peps/pep-0589.rst","contentType":"file"},{"name":"pep-0590.rst","path":"peps/pep-0590.rst","contentType":"file"},{"name":"pep-0591.rst","path":"peps/pep-0591.rst","contentType":"file"},{"name":"pep-0592.rst","path":"peps/pep-0592.rst","contentType":"file"},{"name":"pep-0593.rst","path":"peps/pep-0593.rst","contentType":"file"},{"name":"pep-0594.rst","path":"peps/pep-0594.rst","contentType":"file"},{"name":"pep-0595.rst","path":"peps/pep-0595.rst","contentType":"file"},{"name":"pep-0596.rst","path":"peps/pep-0596.rst","contentType":"file"},{"name":"pep-0597.rst","path":"peps/pep-0597.rst","contentType":"file"},{"name":"pep-0598.rst","path":"peps/pep-0598.rst","contentType":"file"},{"name":"pep-0599.rst","path":"peps/pep-0599.rst","contentType":"file"},{"name":"pep-0600.rst","path":"peps/pep-0600.rst","contentType":"file"},{"name":"pep-0601.rst","path":"peps/pep-0601.rst","contentType":"file"},{"name":"pep-0602-example-release-calendar.png","path":"peps/pep-0602-example-release-calendar.png","contentType":"file"},{"name":"pep-0602-example-release-calendar.pptx","path":"peps/pep-0602-example-release-calendar.pptx","contentType":"file"},{"name":"pep-0602-overlapping-support-matrix.png","path":"peps/pep-0602-overlapping-support-matrix.png","contentType":"file"},{"name":"pep-0602-overlapping-support-matrix.pptx","path":"peps/pep-0602-overlapping-support-matrix.pptx","contentType":"file"},{"name":"pep-0602.rst","path":"peps/pep-0602.rst","contentType":"file"},{"name":"pep-0603-hamt_vs_dict.png","path":"peps/pep-0603-hamt_vs_dict.png","contentType":"file"},{"name":"pep-0603-lookup_hamt.png","path":"peps/pep-0603-lookup_hamt.png","contentType":"file"},{"name":"pep-0603.rst","path":"peps/pep-0603.rst","contentType":"file"},{"name":"pep-0604.rst","path":"peps/pep-0604.rst","contentType":"file"},{"name":"pep-0605-example-release-calendar.png","path":"peps/pep-0605-example-release-calendar.png","contentType":"file"},{"name":"pep-0605-overlapping-support-matrix.png","path":"peps/pep-0605-overlapping-support-matrix.png","contentType":"file"},{"name":"pep-0605.rst","path":"peps/pep-0605.rst","contentType":"file"},{"name":"pep-0606.rst","path":"peps/pep-0606.rst","contentType":"file"},{"name":"pep-0607.rst","path":"peps/pep-0607.rst","contentType":"file"},{"name":"pep-0608.rst","path":"peps/pep-0608.rst","contentType":"file"},{"name":"pep-0609.rst","path":"peps/pep-0609.rst","contentType":"file"},{"name":"pep-0610.rst","path":"peps/pep-0610.rst","contentType":"file"},{"name":"pep-0611.rst","path":"peps/pep-0611.rst","contentType":"file"},{"name":"pep-0612.rst","path":"peps/pep-0612.rst","contentType":"file"},{"name":"pep-0613.rst","path":"peps/pep-0613.rst","contentType":"file"},{"name":"pep-0614.rst","path":"peps/pep-0614.rst","contentType":"file"},{"name":"pep-0615.rst","path":"peps/pep-0615.rst","contentType":"file"},{"name":"pep-0616.rst","path":"peps/pep-0616.rst","contentType":"file"},{"name":"pep-0617.rst","path":"peps/pep-0617.rst","contentType":"file"},{"name":"pep-0618.rst","path":"peps/pep-0618.rst","contentType":"file"},{"name":"pep-0619.rst","path":"peps/pep-0619.rst","contentType":"file"},{"name":"pep-0620.rst","path":"peps/pep-0620.rst","contentType":"file"},{"name":"pep-0621.rst","path":"peps/pep-0621.rst","contentType":"file"},{"name":"pep-0622.rst","path":"peps/pep-0622.rst","contentType":"file"},{"name":"pep-0623.rst","path":"peps/pep-0623.rst","contentType":"file"},{"name":"pep-0624.rst","path":"peps/pep-0624.rst","contentType":"file"},{"name":"pep-0625.rst","path":"peps/pep-0625.rst","contentType":"file"},{"name":"pep-0626.rst","path":"peps/pep-0626.rst","contentType":"file"},{"name":"pep-0627.rst","path":"peps/pep-0627.rst","contentType":"file"},{"name":"pep-0628.rst","path":"peps/pep-0628.rst","contentType":"file"},{"name":"pep-0629.rst","path":"peps/pep-0629.rst","contentType":"file"},{"name":"pep-0630.rst","path":"peps/pep-0630.rst","contentType":"file"},{"name":"pep-0631.rst","path":"peps/pep-0631.rst","contentType":"file"},{"name":"pep-0632.rst","path":"peps/pep-0632.rst","contentType":"file"},{"name":"pep-0633.rst","path":"peps/pep-0633.rst","contentType":"file"},{"name":"pep-0634.rst","path":"peps/pep-0634.rst","contentType":"file"},{"name":"pep-0635.rst","path":"peps/pep-0635.rst","contentType":"file"},{"name":"pep-0636.rst","path":"peps/pep-0636.rst","contentType":"file"},{"name":"pep-0637.rst","path":"peps/pep-0637.rst","contentType":"file"},{"name":"pep-0638.rst","path":"peps/pep-0638.rst","contentType":"file"},{"name":"pep-0639.rst","path":"peps/pep-0639.rst","contentType":"file"},{"name":"pep-0640.rst","path":"peps/pep-0640.rst","contentType":"file"},{"name":"pep-0641.rst","path":"peps/pep-0641.rst","contentType":"file"},{"name":"pep-0642.rst","path":"peps/pep-0642.rst","contentType":"file"},{"name":"pep-0643.rst","path":"peps/pep-0643.rst","contentType":"file"},{"name":"pep-0644.rst","path":"peps/pep-0644.rst","contentType":"file"},{"name":"pep-0645.rst","path":"peps/pep-0645.rst","contentType":"file"},{"name":"pep-0646.rst","path":"peps/pep-0646.rst","contentType":"file"},{"name":"pep-0647.rst","path":"peps/pep-0647.rst","contentType":"file"},{"name":"pep-0648.rst","path":"peps/pep-0648.rst","contentType":"file"},{"name":"pep-0649.rst","path":"peps/pep-0649.rst","contentType":"file"},{"name":"pep-0650.rst","path":"peps/pep-0650.rst","contentType":"file"},{"name":"pep-0651.rst","path":"peps/pep-0651.rst","contentType":"file"},{"name":"pep-0652.rst","path":"peps/pep-0652.rst","contentType":"file"},{"name":"pep-0653.rst","path":"peps/pep-0653.rst","contentType":"file"},{"name":"pep-0654.rst","path":"peps/pep-0654.rst","contentType":"file"},{"name":"pep-0655.rst","path":"peps/pep-0655.rst","contentType":"file"},{"name":"pep-0656.rst","path":"peps/pep-0656.rst","contentType":"file"},{"name":"pep-0657.rst","path":"peps/pep-0657.rst","contentType":"file"},{"name":"pep-0658.rst","path":"peps/pep-0658.rst","contentType":"file"},{"name":"pep-0659.rst","path":"peps/pep-0659.rst","contentType":"file"},{"name":"pep-0660.rst","path":"peps/pep-0660.rst","contentType":"file"},{"name":"pep-0661.rst","path":"peps/pep-0661.rst","contentType":"file"},{"name":"pep-0662.rst","path":"peps/pep-0662.rst","contentType":"file"},{"name":"pep-0663.rst","path":"peps/pep-0663.rst","contentType":"file"},{"name":"pep-0664.rst","path":"peps/pep-0664.rst","contentType":"file"},{"name":"pep-0665.rst","path":"peps/pep-0665.rst","contentType":"file"},{"name":"pep-0666.rst","path":"peps/pep-0666.rst","contentType":"file"},{"name":"pep-0667.rst","path":"peps/pep-0667.rst","contentType":"file"},{"name":"pep-0668.rst","path":"peps/pep-0668.rst","contentType":"file"},{"name":"pep-0669.rst","path":"peps/pep-0669.rst","contentType":"file"},{"name":"pep-0670.rst","path":"peps/pep-0670.rst","contentType":"file"},{"name":"pep-0671.rst","path":"peps/pep-0671.rst","contentType":"file"},{"name":"pep-0672.rst","path":"peps/pep-0672.rst","contentType":"file"},{"name":"pep-0673.rst","path":"peps/pep-0673.rst","contentType":"file"},{"name":"pep-0674.rst","path":"peps/pep-0674.rst","contentType":"file"},{"name":"pep-0675.rst","path":"peps/pep-0675.rst","contentType":"file"},{"name":"pep-0676.rst","path":"peps/pep-0676.rst","contentType":"file"},{"name":"pep-0677.rst","path":"peps/pep-0677.rst","contentType":"file"},{"name":"pep-0678.rst","path":"peps/pep-0678.rst","contentType":"file"},{"name":"pep-0679.rst","path":"peps/pep-0679.rst","contentType":"file"},{"name":"pep-0680.rst","path":"peps/pep-0680.rst","contentType":"file"},{"name":"pep-0681.rst","path":"peps/pep-0681.rst","contentType":"file"},{"name":"pep-0682.rst","path":"peps/pep-0682.rst","contentType":"file"},{"name":"pep-0683.rst","path":"peps/pep-0683.rst","contentType":"file"},{"name":"pep-0684.rst","path":"peps/pep-0684.rst","contentType":"file"},{"name":"pep-0685.rst","path":"peps/pep-0685.rst","contentType":"file"},{"name":"pep-0686.rst","path":"peps/pep-0686.rst","contentType":"file"},{"name":"pep-0687.rst","path":"peps/pep-0687.rst","contentType":"file"},{"name":"pep-0688.rst","path":"peps/pep-0688.rst","contentType":"file"},{"name":"pep-0689.rst","path":"peps/pep-0689.rst","contentType":"file"},{"name":"pep-0690.rst","path":"peps/pep-0690.rst","contentType":"file"},{"name":"pep-0691.rst","path":"peps/pep-0691.rst","contentType":"file"},{"name":"pep-0692.rst","path":"peps/pep-0692.rst","contentType":"file"},{"name":"pep-0693.rst","path":"peps/pep-0693.rst","contentType":"file"},{"name":"pep-0694.rst","path":"peps/pep-0694.rst","contentType":"file"},{"name":"pep-0695.rst","path":"peps/pep-0695.rst","contentType":"file"},{"name":"pep-0696.rst","path":"peps/pep-0696.rst","contentType":"file"},{"name":"pep-0697.rst","path":"peps/pep-0697.rst","contentType":"file"},{"name":"pep-0698.rst","path":"peps/pep-0698.rst","contentType":"file"},{"name":"pep-0699.rst","path":"peps/pep-0699.rst","contentType":"file"},{"name":"pep-0700.rst","path":"peps/pep-0700.rst","contentType":"file"},{"name":"pep-0701.rst","path":"peps/pep-0701.rst","contentType":"file"},{"name":"pep-0702.rst","path":"peps/pep-0702.rst","contentType":"file"},{"name":"pep-0703.rst","path":"peps/pep-0703.rst","contentType":"file"},{"name":"pep-0704.rst","path":"peps/pep-0704.rst","contentType":"file"},{"name":"pep-0705.rst","path":"peps/pep-0705.rst","contentType":"file"},{"name":"pep-0706.rst","path":"peps/pep-0706.rst","contentType":"file"},{"name":"pep-0707.rst","path":"peps/pep-0707.rst","contentType":"file"},{"name":"pep-0708.rst","path":"peps/pep-0708.rst","contentType":"file"},{"name":"pep-0709.rst","path":"peps/pep-0709.rst","contentType":"file"},{"name":"pep-0710.rst","path":"peps/pep-0710.rst","contentType":"file"},{"name":"pep-0711.rst","path":"peps/pep-0711.rst","contentType":"file"},{"name":"pep-0712.rst","path":"peps/pep-0712.rst","contentType":"file"},{"name":"pep-0713.rst","path":"peps/pep-0713.rst","contentType":"file"},{"name":"pep-0714.rst","path":"peps/pep-0714.rst","contentType":"file"},{"name":"pep-0715.rst","path":"peps/pep-0715.rst","contentType":"file"},{"name":"pep-0718.rst","path":"peps/pep-0718.rst","contentType":"file"},{"name":"pep-0719.rst","path":"peps/pep-0719.rst","contentType":"file"},{"name":"pep-0720.rst","path":"peps/pep-0720.rst","contentType":"file"},{"name":"pep-0721.rst","path":"peps/pep-0721.rst","contentType":"file"},{"name":"pep-0722.rst","path":"peps/pep-0722.rst","contentType":"file"},{"name":"pep-0723.rst","path":"peps/pep-0723.rst","contentType":"file"},{"name":"pep-0724.rst","path":"peps/pep-0724.rst","contentType":"file"},{"name":"pep-0725.rst","path":"peps/pep-0725.rst","contentType":"file"},{"name":"pep-0726.rst","path":"peps/pep-0726.rst","contentType":"file"},{"name":"pep-0727.rst","path":"peps/pep-0727.rst","contentType":"file"},{"name":"pep-0728.rst","path":"peps/pep-0728.rst","contentType":"file"},{"name":"pep-0729.rst","path":"peps/pep-0729.rst","contentType":"file"},{"name":"pep-0730.rst","path":"peps/pep-0730.rst","contentType":"file"},{"name":"pep-0731.rst","path":"peps/pep-0731.rst","contentType":"file"},{"name":"pep-0732-concentric.drawio.svg","path":"peps/pep-0732-concentric.drawio.svg","contentType":"file"},{"name":"pep-0732.rst","path":"peps/pep-0732.rst","contentType":"file"},{"name":"pep-0733.rst","path":"peps/pep-0733.rst","contentType":"file"},{"name":"pep-0734.rst","path":"peps/pep-0734.rst","contentType":"file"},{"name":"pep-0735.rst","path":"peps/pep-0735.rst","contentType":"file"},{"name":"pep-0736.rst","path":"peps/pep-0736.rst","contentType":"file"},{"name":"pep-0737.rst","path":"peps/pep-0737.rst","contentType":"file"},{"name":"pep-0738.rst","path":"peps/pep-0738.rst","contentType":"file"},{"name":"pep-0739.rst","path":"peps/pep-0739.rst","contentType":"file"},{"name":"pep-0740.rst","path":"peps/pep-0740.rst","contentType":"file"},{"name":"pep-0741.rst","path":"peps/pep-0741.rst","contentType":"file"},{"name":"pep-0742.rst","path":"peps/pep-0742.rst","contentType":"file"},{"name":"pep-0743.rst","path":"peps/pep-0743.rst","contentType":"file"},{"name":"pep-0744.rst","path":"peps/pep-0744.rst","contentType":"file"},{"name":"pep-0745.rst","path":"peps/pep-0745.rst","contentType":"file"},{"name":"pep-0746.rst","path":"peps/pep-0746.rst","contentType":"file"},{"name":"pep-0747.rst","path":"peps/pep-0747.rst","contentType":"file"},{"name":"pep-0748.rst","path":"peps/pep-0748.rst","contentType":"file"},{"name":"pep-0749.rst","path":"peps/pep-0749.rst","contentType":"file"},{"name":"pep-0750.rst","path":"peps/pep-0750.rst","contentType":"file"},{"name":"pep-0751.rst","path":"peps/pep-0751.rst","contentType":"file"},{"name":"pep-0752.rst","path":"peps/pep-0752.rst","contentType":"file"},{"name":"pep-0753.rst","path":"peps/pep-0753.rst","contentType":"file"},{"name":"pep-0754.rst","path":"peps/pep-0754.rst","contentType":"file"},{"name":"pep-0755.rst","path":"peps/pep-0755.rst","contentType":"file"},{"name":"pep-0756.rst","path":"peps/pep-0756.rst","contentType":"file"},{"name":"pep-0757.rst","path":"peps/pep-0757.rst","contentType":"file"},{"name":"pep-0758.rst","path":"peps/pep-0758.rst","contentType":"file"},{"name":"pep-0759.rst","path":"peps/pep-0759.rst","contentType":"file"},{"name":"pep-0760.rst","path":"peps/pep-0760.rst","contentType":"file"},{"name":"pep-0761.rst","path":"peps/pep-0761.rst","contentType":"file"},{"name":"pep-0762.rst","path":"peps/pep-0762.rst","contentType":"file"},{"name":"pep-0763.rst","path":"peps/pep-0763.rst","contentType":"file"},{"name":"pep-0764.rst","path":"peps/pep-0764.rst","contentType":"file"},{"name":"pep-0765.rst","path":"peps/pep-0765.rst","contentType":"file"},{"name":"pep-0766.rst","path":"peps/pep-0766.rst","contentType":"file"},{"name":"pep-0767.rst","path":"peps/pep-0767.rst","contentType":"file"},{"name":"pep-0768.rst","path":"peps/pep-0768.rst","contentType":"file"},{"name":"pep-0769.rst","path":"peps/pep-0769.rst","contentType":"file"},{"name":"pep-0770.rst","path":"peps/pep-0770.rst","contentType":"file"},{"name":"pep-0771.rst","path":"peps/pep-0771.rst","contentType":"file"},{"name":"pep-0772.rst","path":"peps/pep-0772.rst","contentType":"file"},{"name":"pep-0773.rst","path":"peps/pep-0773.rst","contentType":"file"},{"name":"pep-0774.rst","path":"peps/pep-0774.rst","contentType":"file"},{"name":"pep-0775.rst","path":"peps/pep-0775.rst","contentType":"file"},{"name":"pep-0776.rst","path":"peps/pep-0776.rst","contentType":"file"},{"name":"pep-0777.rst","path":"peps/pep-0777.rst","contentType":"file"},{"name":"pep-0779.rst","path":"peps/pep-0779.rst","contentType":"file"},{"name":"pep-0780.rst","path":"peps/pep-0780.rst","contentType":"file"},{"name":"pep-0781.rst","path":"peps/pep-0781.rst","contentType":"file"},{"name":"pep-0789.rst","path":"peps/pep-0789.rst","contentType":"file"},{"name":"pep-0801.rst","path":"peps/pep-0801.rst","contentType":"file"},{"name":"pep-2026.rst","path":"peps/pep-2026.rst","contentType":"file"},{"name":"pep-3000.rst","path":"peps/pep-3000.rst","contentType":"file"},{"name":"pep-3001.rst","path":"peps/pep-3001.rst","contentType":"file"},{"name":"pep-3002.rst","path":"peps/pep-3002.rst","contentType":"file"},{"name":"pep-3003.rst","path":"peps/pep-3003.rst","contentType":"file"},{"name":"pep-3099.rst","path":"peps/pep-3099.rst","contentType":"file"},{"name":"pep-3100.rst","path":"peps/pep-3100.rst","contentType":"file"},{"name":"pep-3101.rst","path":"peps/pep-3101.rst","contentType":"file"},{"name":"pep-3102.rst","path":"peps/pep-3102.rst","contentType":"file"},{"name":"pep-3103.rst","path":"peps/pep-3103.rst","contentType":"file"},{"name":"pep-3104.rst","path":"peps/pep-3104.rst","contentType":"file"},{"name":"pep-3105.rst","path":"peps/pep-3105.rst","contentType":"file"},{"name":"pep-3106.rst","path":"peps/pep-3106.rst","contentType":"file"},{"name":"pep-3107.rst","path":"peps/pep-3107.rst","contentType":"file"},{"name":"pep-3108.rst","path":"peps/pep-3108.rst","contentType":"file"},{"name":"pep-3109.rst","path":"peps/pep-3109.rst","contentType":"file"},{"name":"pep-3110.rst","path":"peps/pep-3110.rst","contentType":"file"},{"name":"pep-3111.rst","path":"peps/pep-3111.rst","contentType":"file"},{"name":"pep-3112.rst","path":"peps/pep-3112.rst","contentType":"file"},{"name":"pep-3113.rst","path":"peps/pep-3113.rst","contentType":"file"},{"name":"pep-3114.rst","path":"peps/pep-3114.rst","contentType":"file"},{"name":"pep-3115.rst","path":"peps/pep-3115.rst","contentType":"file"},{"name":"pep-3116.rst","path":"peps/pep-3116.rst","contentType":"file"},{"name":"pep-3117.rst","path":"peps/pep-3117.rst","contentType":"file"},{"name":"pep-3118.rst","path":"peps/pep-3118.rst","contentType":"file"},{"name":"pep-3119.rst","path":"peps/pep-3119.rst","contentType":"file"},{"name":"pep-3120.rst","path":"peps/pep-3120.rst","contentType":"file"},{"name":"pep-3121.rst","path":"peps/pep-3121.rst","contentType":"file"},{"name":"pep-3122.rst","path":"peps/pep-3122.rst","contentType":"file"},{"name":"pep-3123.rst","path":"peps/pep-3123.rst","contentType":"file"},{"name":"pep-3124.rst","path":"peps/pep-3124.rst","contentType":"file"},{"name":"pep-3125.rst","path":"peps/pep-3125.rst","contentType":"file"},{"name":"pep-3126.rst","path":"peps/pep-3126.rst","contentType":"file"},{"name":"pep-3127.rst","path":"peps/pep-3127.rst","contentType":"file"},{"name":"pep-3128.rst","path":"peps/pep-3128.rst","contentType":"file"},{"name":"pep-3129.rst","path":"peps/pep-3129.rst","contentType":"file"},{"name":"pep-3130.rst","path":"peps/pep-3130.rst","contentType":"file"},{"name":"pep-3131.rst","path":"peps/pep-3131.rst","contentType":"file"},{"name":"pep-3132.rst","path":"peps/pep-3132.rst","contentType":"file"},{"name":"pep-3133.rst","path":"peps/pep-3133.rst","contentType":"file"},{"name":"pep-3134.rst","path":"peps/pep-3134.rst","contentType":"file"},{"name":"pep-3135.rst","path":"peps/pep-3135.rst","contentType":"file"},{"name":"pep-3136.rst","path":"peps/pep-3136.rst","contentType":"file"},{"name":"pep-3137.rst","path":"peps/pep-3137.rst","contentType":"file"},{"name":"pep-3138.rst","path":"peps/pep-3138.rst","contentType":"file"},{"name":"pep-3139.rst","path":"peps/pep-3139.rst","contentType":"file"},{"name":"pep-3140.rst","path":"peps/pep-3140.rst","contentType":"file"},{"name":"pep-3141.rst","path":"peps/pep-3141.rst","contentType":"file"},{"name":"pep-3142.rst","path":"peps/pep-3142.rst","contentType":"file"},{"name":"pep-3143.rst","path":"peps/pep-3143.rst","contentType":"file"},{"name":"pep-3144.rst","path":"peps/pep-3144.rst","contentType":"file"},{"name":"pep-3145.rst","path":"peps/pep-3145.rst","contentType":"file"},{"name":"pep-3146.rst","path":"peps/pep-3146.rst","contentType":"file"},{"name":"pep-3147-1.dia","path":"peps/pep-3147-1.dia","contentType":"file"},{"name":"pep-3147-1.png","path":"peps/pep-3147-1.png","contentType":"file"},{"name":"pep-3147.rst","path":"peps/pep-3147.rst","contentType":"file"},{"name":"pep-3148.rst","path":"peps/pep-3148.rst","contentType":"file"},{"name":"pep-3149.rst","path":"peps/pep-3149.rst","contentType":"file"},{"name":"pep-3150.rst","path":"peps/pep-3150.rst","contentType":"file"},{"name":"pep-3151.rst","path":"peps/pep-3151.rst","contentType":"file"},{"name":"pep-3152.rst","path":"peps/pep-3152.rst","contentType":"file"},{"name":"pep-3153.rst","path":"peps/pep-3153.rst","contentType":"file"},{"name":"pep-3154.rst","path":"peps/pep-3154.rst","contentType":"file"},{"name":"pep-3155.rst","path":"peps/pep-3155.rst","contentType":"file"},{"name":"pep-3156.rst","path":"peps/pep-3156.rst","contentType":"file"},{"name":"pep-3333.rst","path":"peps/pep-3333.rst","contentType":"file"},{"name":"pep-789-example-no-yield.png","path":"peps/pep-789-example-no-yield.png","contentType":"file"},{"name":"pep-789-example-yield-allowed.png","path":"peps/pep-789-example-yield-allowed.png","contentType":"file"},{"name":"pep-789-example-yield-errors.png","path":"peps/pep-789-example-yield-errors.png","contentType":"file"},{"name":"pep-8000.rst","path":"peps/pep-8000.rst","contentType":"file"},{"name":"pep-8001.rst","path":"peps/pep-8001.rst","contentType":"file"},{"name":"pep-8002.rst","path":"peps/pep-8002.rst","contentType":"file"},{"name":"pep-8010.rst","path":"peps/pep-8010.rst","contentType":"file"},{"name":"pep-8011.rst","path":"peps/pep-8011.rst","contentType":"file"},{"name":"pep-8012.rst","path":"peps/pep-8012.rst","contentType":"file"},{"name":"pep-8013.rst","path":"peps/pep-8013.rst","contentType":"file"},{"name":"pep-8014.rst","path":"peps/pep-8014.rst","contentType":"file"},{"name":"pep-8015.rst","path":"peps/pep-8015.rst","contentType":"file"},{"name":"pep-8016.rst","path":"peps/pep-8016.rst","contentType":"file"},{"name":"pep-8100.rst","path":"peps/pep-8100.rst","contentType":"file"},{"name":"pep-8101.rst","path":"peps/pep-8101.rst","contentType":"file"},{"name":"pep-8102.rst","path":"peps/pep-8102.rst","contentType":"file"},{"name":"pep-8103.rst","path":"peps/pep-8103.rst","contentType":"file"},{"name":"pep-8104.rst","path":"peps/pep-8104.rst","contentType":"file"},{"name":"pep-8105.rst","path":"peps/pep-8105.rst","contentType":"file"},{"name":"pep-8106.rst","path":"peps/pep-8106.rst","contentType":"file"}],"totalCount":720},"":{"items":[{"name":".codespell","path":".codespell","contentType":"directory"},{"name":".github","path":".github","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"infra","path":"infra","contentType":"directory"},{"name":"pep_sphinx_extensions","path":"pep_sphinx_extensions","contentType":"directory"},{"name":"peps","path":"peps","contentType":"directory"},{"name":".codespellrc","path":".codespellrc","contentType":"file"},{"name":".gitattributes","path":".gitattributes","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","contentType":"file"},{"name":".readthedocs.yaml","path":".readthedocs.yaml","contentType":"file"},{"name":".ruff.toml","path":".ruff.toml","contentType":"file"},{"name":"CONTRIBUTING.rst","path":"CONTRIBUTING.rst","contentType":"file"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"README.rst","path":"README.rst","contentType":"file"},{"name":"build.py","path":"build.py","contentType":"file"},{"name":"check-peps.py","path":"check-peps.py","contentType":"file"},{"name":"pytest.ini","path":"pytest.ini","contentType":"file"},{"name":"requirements.txt","path":"requirements.txt","contentType":"file"},{"name":"tox.ini","path":"tox.ini","contentType":"file"}],"totalCount":20}},"fileTreeProcessingTime":159.267664,"foldersToFetch":[],"repo":{"id":13414105,"defaultBranch":"main","name":"peps","ownerLogin":"python","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2013-10-08T13:27:12.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1525981?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"main","listCacheKey":"v0:1736207583.0","canEdit":false,"refType":"branch","currentOid":"2f2c7ee65e36dbac2d0172113bab0a5c8a667e09"},"path":"peps/pep-0622.rst","currentUser":null,"blob":{"rawLines":null,"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/python/peps/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"pep-0622.rst","displayUrl":"https://github.com/python/peps/blob/main/peps/pep-0622.rst?raw=true","headerInfo":{"blobSize":"86.4 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"299ddeb","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fpeps%2Fblob%2Fmain%2Fpeps%2Fpep-0622.rst","isCSV":false,"isRichtext":true,"toc":[{"level":2,"text":"Abstract","anchor":"abstract","htmlText":"Abstract"},{"level":3,"text":"Patterns and shapes","anchor":"patterns-and-shapes","htmlText":"Patterns and shapes"},{"level":3,"text":"Syntax","anchor":"syntax","htmlText":"Syntax"},{"level":3,"text":"Motivation","anchor":"motivation","htmlText":"Motivation"},{"level":2,"text":"Overview","anchor":"overview","htmlText":"Overview"},{"level":3,"text":"Pattern, a new syntactic construct, and destructuring","anchor":"pattern-a-new-syntactic-construct-and-destructuring","htmlText":"Pattern, a new syntactic construct, and destructuring"},{"level":3,"text":"Matching process","anchor":"matching-process","htmlText":"Matching process"},{"level":2,"text":"Rationale and Goals","anchor":"rationale-and-goals","htmlText":"Rationale and Goals"},{"level":2,"text":"Syntax and Semantics","anchor":"syntax-and-semantics","htmlText":"Syntax and Semantics"},{"level":3,"text":"Patterns","anchor":"patterns","htmlText":"Patterns"},{"level":3,"text":"The match statement","anchor":"the-match-statement","htmlText":"The match statement"},{"level":3,"text":"Match semantics","anchor":"match-semantics","htmlText":"Match semantics"},{"level":3,"text":"Allowed patterns","anchor":"allowed-patterns","htmlText":"Allowed patterns"},{"level":4,"text":"Literal Patterns","anchor":"literal-patterns","htmlText":"Literal Patterns"},{"level":4,"text":"Capture Patterns","anchor":"capture-patterns","htmlText":"Capture Patterns"},{"level":4,"text":"Wildcard Pattern","anchor":"wildcard-pattern","htmlText":"Wildcard Pattern"},{"level":4,"text":"Constant Value Patterns","anchor":"constant-value-patterns","htmlText":"Constant Value Patterns"},{"level":4,"text":"Sequence Patterns","anchor":"sequence-patterns","htmlText":"Sequence Patterns"},{"level":4,"text":"Mapping Patterns","anchor":"mapping-patterns","htmlText":"Mapping Patterns"},{"level":4,"text":"Class Patterns","anchor":"class-patterns","htmlText":"Class Patterns"},{"level":3,"text":"Combining multiple patterns (OR patterns)","anchor":"combining-multiple-patterns-or-patterns","htmlText":"Combining multiple patterns (OR patterns)"},{"level":3,"text":"Guards","anchor":"guards","htmlText":"Guards"},{"level":3,"text":"Walrus patterns","anchor":"walrus-patterns","htmlText":"Walrus patterns"},{"level":2,"text":"Runtime specification","anchor":"runtime-specification","htmlText":"Runtime specification"},{"level":3,"text":"The Match Protocol","anchor":"the-match-protocol","htmlText":"The Match Protocol"},{"level":3,"text":"Overlapping sub-patterns","anchor":"overlapping-sub-patterns","htmlText":"Overlapping sub-patterns"},{"level":3,"text":"Special attribute __match_args__","anchor":"special-attribute-__match_args__","htmlText":"Special attribute __match_args__"},{"level":3,"text":"Exceptions and side effects","anchor":"exceptions-and-side-effects","htmlText":"Exceptions and side effects"},{"level":3,"text":"The standard library","anchor":"the-standard-library","htmlText":"The standard library"},{"level":2,"text":"Static checkers specification","anchor":"static-checkers-specification","htmlText":"Static checkers specification"},{"level":3,"text":"Exhaustiveness checks","anchor":"exhaustiveness-checks","htmlText":"Exhaustiveness checks"},{"level":3,"text":"Sealed classes as algebraic data types","anchor":"sealed-classes-as-algebraic-data-types","htmlText":"Sealed classes as algebraic data types"},{"level":3,"text":"Type erasure","anchor":"type-erasure","htmlText":"Type erasure"},{"level":3,"text":"Note about constants","anchor":"note-about-constants","htmlText":"Note about constants"},{"level":3,"text":"Precise type checking of star matches","anchor":"precise-type-checking-of-star-matches","htmlText":"Precise type checking of star matches"},{"level":2,"text":"Performance Considerations","anchor":"performance-considerations","htmlText":"Performance Considerations"},{"level":2,"text":"Backwards Compatibility","anchor":"backwards-compatibility","htmlText":"Backwards Compatibility"},{"level":2,"text":"Impacts on third-party tools","anchor":"impacts-on-third-party-tools","htmlText":"Impacts on third-party tools"},{"level":2,"text":"Reference Implementation","anchor":"reference-implementation","htmlText":"Reference Implementation"},{"level":2,"text":"Example Code","anchor":"example-code","htmlText":"Example Code"},{"level":2,"text":"Rejected Ideas","anchor":"rejected-ideas","htmlText":"Rejected Ideas"},{"level":3,"text":"Don't do this, pattern matching is hard to learn","anchor":"dont-do-this-pattern-matching-is-hard-to-learn","htmlText":"Don't do this, pattern matching is hard to learn"},{"level":3,"text":"Don't do this, use existing method dispatching mechanisms","anchor":"dont-do-this-use-existing-method-dispatching-mechanisms","htmlText":"Don't do this, use existing method dispatching mechanisms"},{"level":3,"text":"Allow more flexible assignment targets instead","anchor":"allow-more-flexible-assignment-targets-instead","htmlText":"Allow more flexible assignment targets instead"},{"level":3,"text":"Make it an expression","anchor":"make-it-an-expression","htmlText":"Make it an expression"},{"level":3,"text":"Use a hard keyword","anchor":"use-a-hard-keyword","htmlText":"Use a hard keyword"},{"level":3,"text":"Use as or | instead of case for case clauses","anchor":"use-as-or--instead-of-case-for-case-clauses","htmlText":"Use as or | instead of case for case clauses"},{"level":3,"text":"Use a flat indentation scheme","anchor":"use-a-flat-indentation-scheme","htmlText":"Use a flat indentation scheme"},{"level":3,"text":"Alternatives for constant value pattern","anchor":"alternatives-for-constant-value-pattern","htmlText":"Alternatives for constant value pattern"},{"level":3,"text":"Disallow float literals in patterns","anchor":"disallow-float-literals-in-patterns","htmlText":"Disallow float literals in patterns"},{"level":3,"text":"Range matching patterns","anchor":"range-matching-patterns","htmlText":"Range matching patterns"},{"level":3,"text":"Use dispatch dict semantics for matches","anchor":"use-dispatch-dict-semantics-for-matches","htmlText":"Use dispatch dict semantics for matches"},{"level":3,"text":"Use continue and break in case clauses.","anchor":"use-continue-and-break-in-case-clauses","htmlText":"Use continue and break in case clauses."},{"level":3,"text":"AND (\u0026) patterns","anchor":"and--patterns","htmlText":"AND (\u0026amp;) patterns"},{"level":3,"text":"Negative match patterns","anchor":"negative-match-patterns","htmlText":"Negative match patterns"},{"level":3,"text":"Check exhaustiveness at runtime","anchor":"check-exhaustiveness-at-runtime","htmlText":"Check exhaustiveness at runtime"},{"level":3,"text":"Type annotations for pattern variables","anchor":"type-annotations-for-pattern-variables","htmlText":"Type annotations for pattern variables"},{"level":3,"text":"Allow *rest in class patterns","anchor":"allow-rest-in-class-patterns","htmlText":"Allow *rest in class patterns"},{"level":3,"text":"Disallow _.a in constant value patterns","anchor":"disallow-_a-in-constant-value-patterns","htmlText":"Disallow _.a in constant value patterns"},{"level":3,"text":"Use some other token as wildcard","anchor":"use-some-other-token-as-wildcard","htmlText":"Use some other token as wildcard"},{"level":3,"text":"Use some other syntax instead of | for OR patterns","anchor":"use-some-other-syntax-instead-of--for-or-patterns","htmlText":"Use some other syntax instead of | for OR patterns"},{"level":3,"text":"Add an else clause","anchor":"add-an-else-clause","htmlText":"Add an else clause"},{"level":2,"text":"Deferred Ideas","anchor":"deferred-ideas","htmlText":"Deferred Ideas"},{"level":3,"text":"One-off syntax variant","anchor":"one-off-syntax-variant","htmlText":"One-off syntax variant"},{"level":3,"text":"Other pattern-based constructions","anchor":"other-pattern-based-constructions","htmlText":"Other pattern-based constructions"},{"level":3,"text":"Algebraic matching of repeated names","anchor":"algebraic-matching-of-repeated-names","htmlText":"Algebraic matching of repeated names"},{"level":3,"text":"Custom matching protocol","anchor":"custom-matching-protocol","htmlText":"Custom matching protocol"},{"level":3,"text":"Parameterized Matching Syntax","anchor":"parameterized-matching-syntax","htmlText":"Parameterized Matching Syntax"},{"level":3,"text":"Pattern Utility Library","anchor":"pattern-utility-library","htmlText":"Pattern Utility Library"},{"level":2,"text":"Acknowledgments","anchor":"acknowledgments","htmlText":"Acknowledgments"},{"level":2,"text":"Version History","anchor":"version-history","htmlText":"Version History"},{"level":2,"text":"References","anchor":"references","htmlText":"References"},{"level":2,"text":"Appendix A -- Full Grammar","anchor":"appendix-a----full-grammar","htmlText":"Appendix A -- Full Grammar"},{"level":2,"text":"Copyright","anchor":"copyright","htmlText":"Copyright"}],"lineInfo":{"truncatedLoc":"2277","truncatedSloc":"1747"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"reStructuredText","languageID":419,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/python/peps/blob/main/peps/pep-0622.rst","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/python/peps/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/python/peps/raw/refs/heads/main/peps/pep-0622.rst","renderImageOrRaw":false,"richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cp dir=\"auto\"\u003ePEP: 622\nTitle: Structural Pattern Matching\nAuthor: Brandt Bucher \u0026lt;\u003ca href=\"mailto:brandt@python.org\"\u003ebrandt@python.org\u003c/a\u003e\u0026gt;,\u003c/p\u003e\n\u003cblockquote\u003e\nDaniel F Moisset \u0026lt;\u003ca href=\"mailto:dfmoisset@gmail.com\"\u003edfmoisset@gmail.com\u003c/a\u003e\u0026gt;,\nTobias Kohn \u0026lt;\u003ca href=\"mailto:kohnt@tobiaskohn.ch\"\u003ekohnt@tobiaskohn.ch\u003c/a\u003e\u0026gt;,\nIvan Levkivskyi \u0026lt;\u003ca href=\"mailto:levkivskyi@gmail.com\"\u003elevkivskyi@gmail.com\u003c/a\u003e\u0026gt;,\nGuido van Rossum \u0026lt;\u003ca href=\"mailto:guido@python.org\"\u003eguido@python.org\u003c/a\u003e\u0026gt;,\nTalin \u0026lt;\u003ca href=\"mailto:viridia@gmail.com\"\u003eviridia@gmail.com\u003c/a\u003e\u0026gt;\u003c/blockquote\u003e\n\u003cp dir=\"auto\"\u003eBDFL-Delegate:\nDiscussions-To: \u003ca href=\"mailto:python-dev@python.org\"\u003epython-dev@python.org\u003c/a\u003e\nStatus: Superseded\nType: Standards Track\nCreated: 23-Jun-2020\nPython-Version: 3.10\nPost-History: 23-Jun-2020, 08-Jul-2020\nSuperseded-By: 634\u003c/p\u003e\n\u003ca name=\"user-content-abstract\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAbstract\u003c/h2\u003e\u003ca id=\"user-content-abstract\" class=\"anchor\" aria-label=\"Permalink: Abstract\" href=\"#abstract\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis PEP proposes to add a \u003cstrong\u003epattern matching statement\u003c/strong\u003e to Python,\ninspired by similar syntax found in Scala, Erlang, and other languages.\u003c/p\u003e\n\u003ca name=\"user-content-patterns-and-shapes\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePatterns and shapes\u003c/h3\u003e\u003ca id=\"user-content-patterns-and-shapes\" class=\"anchor\" aria-label=\"Permalink: Patterns and shapes\" href=\"#patterns-and-shapes\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe \u003cstrong\u003epattern syntax\u003c/strong\u003e builds on Python’s existing syntax for sequence\nunpacking (e.g., \u003ccode\u003ea, b = value\u003c/code\u003e).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eA \u003ccode\u003ematch\u003c/code\u003e statement compares a value (the \u003cstrong\u003esubject\u003c/strong\u003e)\nto several different shapes (the \u003cstrong\u003epatterns\u003c/strong\u003e) until a shape fits.\nEach pattern describes the type and structure of the accepted values\nas well as the variables where to capture its contents.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003ePatterns can specify the shape to be:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003ea sequence to be unpacked, as already mentioned\u003c/li\u003e\n\u003cli\u003ea mapping with specific keys\u003c/li\u003e\n\u003cli\u003ean instance of a given class with (optionally) specific attributes\u003c/li\u003e\n\u003cli\u003ea specific value\u003c/li\u003e\n\u003cli\u003ea wildcard\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003ePatterns can be composed in several ways.\u003c/p\u003e\n\u003ca name=\"user-content-syntax\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSyntax\u003c/h3\u003e\u003ca id=\"user-content-syntax\" class=\"anchor\" aria-label=\"Permalink: Syntax\" href=\"#syntax\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSyntactically, a \u003ccode\u003ematch\u003c/code\u003e statement contains:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003ea \u003cem\u003esubject\u003c/em\u003e expression\u003c/li\u003e\n\u003cli\u003eone or more \u003ccode\u003ecase\u003c/code\u003e clauses\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eEach \u003ccode\u003ecase\u003c/code\u003e clause specifies:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003ea pattern (the overall shape to be matched)\u003c/li\u003e\n\u003cli\u003ean optional “guard” (a condition to be checked if the pattern matches)\u003c/li\u003e\n\u003cli\u003ea code block to be executed if the case clause is selected\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-motivation\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMotivation\u003c/h3\u003e\u003ca id=\"user-content-motivation\" class=\"anchor\" aria-label=\"Permalink: Motivation\" href=\"#motivation\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe rest of the PEP:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003emotivates why we believe pattern matching makes a good addition to Python\u003c/li\u003e\n\u003cli\u003eexplains our design choices\u003c/li\u003e\n\u003cli\u003econtains a precise syntactic and runtime specification\u003c/li\u003e\n\u003cli\u003egives guidance for static type checkers (and one small addition to the \u003ccode\u003etyping\u003c/code\u003e module)\u003c/li\u003e\n\u003cli\u003ediscusses the main objections and alternatives that have been\nbrought up during extensive discussion of the proposal, both within\nthe group of authors and in the python-dev community\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eFinally, we discuss some possible extensions that might be considered\nin the future, once the community has ample experience with the\ncurrently proposed syntax and semantics.\u003c/p\u003e\n\u003ca name=\"user-content-overview\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eOverview\u003c/h2\u003e\u003ca id=\"user-content-overview\" class=\"anchor\" aria-label=\"Permalink: Overview\" href=\"#overview\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003ePatterns are a new syntactical category with their own rules\nand special cases. Patterns mix input (given values) and output\n(captured variables) in novel ways. They may take a little time to\nuse effectively. The authors have provided\na brief introduction to the basic concepts here. Note that this section\nis not intended to be complete or entirely accurate.\u003c/p\u003e\n\u003ca name=\"user-content-pattern-a-new-syntactic-construct-and-destructuring\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePattern, a new syntactic construct, and destructuring\u003c/h3\u003e\u003ca id=\"user-content-pattern-a-new-syntactic-construct-and-destructuring\" class=\"anchor\" aria-label=\"Permalink: Pattern, a new syntactic construct, and destructuring\" href=\"#pattern-a-new-syntactic-construct-and-destructuring\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA new syntactic construct called \u003cstrong\u003epattern\u003c/strong\u003e is introduced in this\nPEP. Syntactically, patterns look like a subset of expressions.\nThe following are examples of patterns:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003e[first, second, *rest]\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ePoint2d(x, 0)\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e{\"name\": \"Bruce\", \"age\": age}\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e42\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eThe above expressions may look like examples of object construction\nwith a constructor which takes some values as parameters and\nbuilds an object from those components.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWhen viewed as a pattern, the above patterns mean the inverse operation of\nconstruction, which we call \u003cstrong\u003edestructuring\u003c/strong\u003e. \u003cstrong\u003eDestructuring\u003c/strong\u003e takes a subject value\nand extracts its components.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe syntactic similarity between object construction and destructuring is\nintentional. It also follows the existing\nPythonic style of contexts which makes assignment targets (write contexts) look\nlike expressions (read contexts).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003ePattern matching never creates objects. This is in the same way that\n\u003ccode\u003e[a, b] = my_list\u003c/code\u003e doesn't create a\nnew \u003ccode\u003e[a, b]\u003c/code\u003e list, nor reads the values of \u003ccode\u003ea\u003c/code\u003e and \u003ccode\u003eb\u003c/code\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-matching-process\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMatching process\u003c/h3\u003e\u003ca id=\"user-content-matching-process\" class=\"anchor\" aria-label=\"Permalink: Matching process\" href=\"#matching-process\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eDuring this matching process,\nthe structure of the pattern may not fit the subject, and matching \u003cem\u003efails\u003c/em\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor example, matching the pattern \u003ccode\u003ePoint2d(x, 0)\u003c/code\u003e to the subject\n\u003ccode\u003ePoint2d(3, 0)\u003c/code\u003e successfully matches. The match also \u003cstrong\u003ebinds\u003c/strong\u003e\nthe pattern's free variable \u003ccode\u003ex\u003c/code\u003e to the subject's value \u003ccode\u003e3\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAs another example, if the subject is \u003ccode\u003e[3, 0]\u003c/code\u003e, the match fails\nbecause the subject's type \u003ccode\u003elist\u003c/code\u003e is not the pattern's \u003ccode\u003ePoint2d\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAs a third example, if the subject is\n\u003ccode\u003ePoint2d(3, 7)\u003c/code\u003e, the match fails because the\nsubject's second coordinate \u003ccode\u003e7\u003c/code\u003e is not the same as the pattern's \u003ccode\u003e0\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode\u003ematch\u003c/code\u003e statement tries to match a single subject to each of the\npatterns in its \u003ccode\u003ecase\u003c/code\u003e clauses. At the first\nsuccessful match to a pattern in a \u003ccode\u003ecase\u003c/code\u003e clause:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003ethe variables in the pattern are assigned, and\u003c/li\u003e\n\u003cli\u003ea corresponding block is executed.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eEach \u003ccode\u003ecase\u003c/code\u003e clause can also specify an optional boolean condition,\nknown as a \u003cstrong\u003eguard\u003c/strong\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eLet's look at a more detailed example of a \u003ccode\u003ematch\u003c/code\u003e statement. The\n\u003ccode\u003ematch\u003c/code\u003e statement is used within a function to define the building\nof 3D points. In this example, the function can accept as input any of\nthe following: tuple with 2 elements, tuple with 3 elements, an\nexisting Point2d object or an existing Point3d object:\u003c/p\u003e\n\u003cpre\u003edef make_point_3d(pt):\n match pt:\n case (x, y):\n return Point3d(x, y, 0)\n case (x, y, z):\n return Point3d(x, y, z)\n case Point2d(x, y):\n return Point3d(x, y, 0)\n case Point3d(_, _, _):\n return pt\n case _:\n raise TypeError(\"not a point we support\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eWithout pattern matching, this function's implementation would require several\n\u003ccode\u003eisinstance()\u003c/code\u003e checks, one or two \u003ccode\u003elen()\u003c/code\u003e calls, and a more\nconvoluted control flow. The \u003ccode\u003ematch\u003c/code\u003e example version and the traditional\nPython version without \u003ccode\u003ematch\u003c/code\u003e translate into similar code under the hood.\nWith familiarity of pattern matching, a user reading this function using \u003ccode\u003ematch\u003c/code\u003e\nwill likely find this version clearer than the traditional approach.\u003c/p\u003e\n\u003ca name=\"user-content-rationale-and-goals\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRationale and Goals\u003c/h2\u003e\u003ca id=\"user-content-rationale-and-goals\" class=\"anchor\" aria-label=\"Permalink: Rationale and Goals\" href=\"#rationale-and-goals\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003ePython programs frequently need to handle data which varies in type,\npresence of attributes/keys, or number of elements. Typical examples\nare operating on nodes of a mixed structure like an AST, handling UI\nevents of different types, processing structured input (like\nstructured files or network messages), or “parsing” arguments for a\nfunction that can accept different combinations of types and numbers\nof parameters. In fact, the classic 'visitor' pattern is an example of this,\ndone in an OOP style -- but matching makes it much less tedious to write.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eMuch of the code to do so tends to consist of complex chains of nested\n\u003ccode\u003eif\u003c/code\u003e/\u003ccode\u003eelif\u003c/code\u003e statements, including multiple calls to \u003ccode\u003elen()\u003c/code\u003e,\n\u003ccode\u003eisinstance()\u003c/code\u003e and index/key/attribute access. Inside those branches\nusers sometimes need to destructure the data further to extract the\nrequired component values, which may be nested several objects deep.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003ePattern matching as present in many other languages provides an\nelegant solution to this problem. These range from statically compiled\nfunctional languages like F# and Haskell, via mixed-paradigm languages\nlike \u003ca href=\"https://docs.scala-lang.org/tour/pattern-matching.html\" rel=\"nofollow\"\u003eScala\u003c/a\u003e and \u003ca href=\"https://doc.rust-lang.org/reference/patterns.html\" rel=\"nofollow\"\u003eRust\u003c/a\u003e, to dynamic languages like Elixir and\nRuby, and is under consideration for JavaScript. We are indebted to\nthese languages for guiding the way to Pythonic pattern matching, as\nPython is indebted to so many other languages for many of its\nfeatures: many basic syntactic features were inherited from C,\nexceptions from Modula-3, classes were inspired by C++, slicing came\nfrom Icon, regular expressions from Perl, decorators resemble Java\nannotations, and so on.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe usual logic for operating on heterogeneous data can be summarized\nin the following way:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eSome analysis is done on the \u003cem\u003eshape\u003c/em\u003e (type and components) of the\ndata: This could involve \u003ccode\u003eisinstance()\u003c/code\u003e or \u003ccode\u003elen()\u003c/code\u003e calls and/or extracting\ncomponents (via indexing or attribute access) which are checked for\nspecific values or conditions.\u003c/li\u003e\n\u003cli\u003eIf the shape is as expected, some more components are possibly\nextracted and some operation is done using the extracted values.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eTake for example \u003ca href=\"https://github.com/django/django/blob/5166097d7c80cab757e44f2d02f3d148fbbc2ff6/django/db/models/enums.py#L13\"\u003ethis piece of the Django web framework\u003c/a\u003e:\u003c/p\u003e\n\u003cpre\u003eif (\n isinstance(value, (list, tuple)) and\n len(value) \u0026gt; 1 and\n isinstance(value[-1], (Promise, str))\n):\n *value, label = value\n value = tuple(value)\nelse:\n label = key.replace('_', ' ').title()\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eWe can see the shape analysis of the \u003ccode\u003evalue\u003c/code\u003e at the top, following\nby the destructuring inside.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that shape analysis here involves checking the types both of the\ncontainer and of one of its components, and some checks on its number\nof elements. Once we match the shape, we need to decompose the\nsequence. With the proposal in this PEP, we could rewrite that code\ninto this:\u003c/p\u003e\n\u003cpre\u003ematch value:\n case [*v, label := (Promise() | str())] if v:\n value = tuple(v)\n case _:\n label = key.replace('_', ' ').title()\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis syntax makes much more explicit which formats are possible for\nthe input data, and which components are extracted from where. You can\nsee a pattern similar to list unpacking, but also type checking: the\n\u003ccode\u003ePromise()\u003c/code\u003e pattern is not an object construction, but represents\nanything that's an instance of \u003ccode\u003ePromise\u003c/code\u003e. The pattern operator \u003ccode\u003e|\u003c/code\u003e\nseparates alternative patterns (not unlike regular expressions or EBNF\ngrammars), and \u003ccode\u003e_\u003c/code\u003e is a wildcard. (Note that the match syntax used\nhere will accept user-defined sequences, as well as lists and tuples.)\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn some occasions, extraction of information is not as relevant as\nidentifying structure. Take the following example from the\n\u003ca href=\"https://github.com/python/cpython/blob/c4cacc8/Lib/lib2to3/fixer_util.py#L158\"\u003ePython standard library\u003c/a\u003e:\u003c/p\u003e\n\u003cpre\u003edef is_tuple(node):\n if isinstance(node, Node) and node.children == [LParen(), RParen()]:\n return True\n return (isinstance(node, Node)\n and len(node.children) == 3\n and isinstance(node.children[0], Leaf)\n and isinstance(node.children[1], Node)\n and isinstance(node.children[2], Leaf)\n and node.children[0].value == \"(\"\n and node.children[2].value == \")\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis example shows an example of finding out the \"shape\" of the data\nwithout doing significant extraction. This code is not very easy to\nread, and the intended shape that this is trying to match is not\nevident. Compare with the updated code using the proposed syntax:\u003c/p\u003e\n\u003cpre\u003edef is_tuple(node: Node) -\u0026gt; bool:\n match node:\n case Node(children=[LParen(), RParen()]):\n return True\n case Node(children=[Leaf(value=\"(\"), Node(), Leaf(value=\")\")]):\n return True\n case _:\n return False\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eNote that the proposed code will work without any modifications to the\ndefinition of \u003ccode\u003eNode\u003c/code\u003e and other classes here. As shown in the\nexamples above, the proposal supports not just unpacking sequences, but\nalso doing \u003ccode\u003eisinstance\u003c/code\u003e checks (like \u003ccode\u003eLParen()\u003c/code\u003e or \u003ccode\u003estr()\u003c/code\u003e),\nlooking into object attributes (\u003ccode\u003eLeaf(value=\"(\")\u003c/code\u003e for example) and\ncomparisons with literals.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThat last feature helps with some kinds of code which look more like\nthe \"switch\" statement as present in other languages:\u003c/p\u003e\n\u003cpre\u003ematch response.status:\n case 200:\n do_something(response.data) # OK\n case 301 | 302:\n retry(response.location) # Redirect\n case 401:\n retry(auth=get_credentials()) # Login first\n case 426:\n sleep(DELAY) # Server is swamped, try after a bit\n retry()\n case _:\n raise RequestError(\"we couldn't get the data\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eAlthough this will work, it's not necessarily what the proposal is\nfocused on, and the new syntax has been designed to best support the\ndestructuring scenarios.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eSee the \u003ca href=\"#syntax-and-semantics\"\u003esyntax\u003c/a\u003e sections below\nfor a more detailed specification.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe propose that destructuring objects can be customized by a new\nspecial \u003ccode\u003e__match_args__\u003c/code\u003e attribute. As part of this PEP we specify\nthe general API and its implementation for some standard library\nclasses (including named tuples and dataclasses). See the \u003ca href=\"#runtime-specification\"\u003eruntime\u003c/a\u003e section below.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFinally, we aim to provide comprehensive support for static type\ncheckers and similar tools. For this purpose, we propose to introduce\na \u003ccode\u003e@typing.sealed\u003c/code\u003e class decorator that will be a no-op at runtime\nbut will indicate to static tools that all sub-classes of this class\nmust be defined in the same module. This will allow effective static\nexhaustiveness checks, and together with dataclasses, will provide\nbasic support for \u003ca href=\"https://en.wikipedia.org/wiki/Algebraic_data_type\" rel=\"nofollow\"\u003ealgebraic data types\u003c/a\u003e. See the \u003ca href=\"#static-checkers-specification\"\u003estatic checkers\u003c/a\u003e section for more details.\u003c/p\u003e\n\u003ca name=\"user-content-syntax-and-semantics\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSyntax and Semantics\u003c/h2\u003e\u003ca id=\"user-content-syntax-and-semantics\" class=\"anchor\" aria-label=\"Permalink: Syntax and Semantics\" href=\"#syntax-and-semantics\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003ca name=\"user-content-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePatterns\u003c/h3\u003e\u003ca id=\"user-content-patterns\" class=\"anchor\" aria-label=\"Permalink: Patterns\" href=\"#patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe \u003cstrong\u003epattern\u003c/strong\u003e is a new syntactic construct, that could be considered a loose\ngeneralization of assignment targets. The key properties of a pattern are what\ntypes and shapes of subjects it accepts, what variables it captures and how\nit extracts them from the subject. For example, the pattern \u003ccode\u003e[a, b]\u003c/code\u003e matches\nonly sequences of exactly 2 elements, extracting the first element into \u003ccode\u003ea\u003c/code\u003e\nand the second one into \u003ccode\u003eb\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis PEP defines several types of patterns. These are certainly not the\nonly possible ones, so the design decision was made to choose a subset of\nfunctionality that is useful now but conservative. More patterns can be added\nlater as this feature gets more widespread use. See the \u003ca href=\"#rejected-ideas\"\u003erejected ideas\u003c/a\u003e\nand \u003ca href=\"#deferred-ideas\"\u003edeferred ideas\u003c/a\u003e sections for more details.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe patterns listed here are described in more detail below, but summarized\ntogether in this section for simplicity:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eA \u003cstrong\u003eliteral pattern\u003c/strong\u003e is useful to filter constant values in a structure.\nIt looks like a Python literal (including some values like \u003ccode\u003eTrue\u003c/code\u003e,\n\u003ccode\u003eFalse\u003c/code\u003e and \u003ccode\u003eNone\u003c/code\u003e). It only matches objects equal to the literal, and\nnever binds.\u003c/li\u003e\n\u003cli\u003eA \u003cstrong\u003ecapture pattern\u003c/strong\u003e looks like \u003ccode\u003ex\u003c/code\u003e and is equivalent to an identical\nassignment target: it always matches and binds the variable\nwith the given (simple) name.\u003c/li\u003e\n\u003cli\u003eThe \u003cstrong\u003ewildcard pattern\u003c/strong\u003e is a single underscore: \u003ccode\u003e_\u003c/code\u003e. It always matches,\nbut does not capture any variable (which prevents interference with other\nuses for \u003ccode\u003e_\u003c/code\u003e and allows for some optimizations).\u003c/li\u003e\n\u003cli\u003eA \u003cstrong\u003econstant value pattern\u003c/strong\u003e works like the literal but for certain named\nconstants. Note that it must be a qualified (dotted) name, given the possible\nambiguity with a capture pattern. It looks like \u003ccode\u003eColor.RED\u003c/code\u003e and\nonly matches values equal to the corresponding value. It never binds.\u003c/li\u003e\n\u003cli\u003eA \u003cstrong\u003esequence pattern\u003c/strong\u003e looks like \u003ccode\u003e[a, *rest, b]\u003c/code\u003e and is similar to\na list unpacking. An important difference is that the elements nested\nwithin it can be any kind of patterns, not just names or sequences.\nIt matches only sequences of appropriate length, as long as all the sub-patterns\nalso match. It makes all the bindings of its sub-patterns.\u003c/li\u003e\n\u003cli\u003eA \u003cstrong\u003emapping pattern\u003c/strong\u003e looks like \u003ccode\u003e{\"user\": u, \"emails\": [*es]}\u003c/code\u003e. It matches\nmappings with at least the set of provided keys, and if all the\nsub-patterns match their corresponding values. It binds whatever the\nsub-patterns bind while matching with the values corresponding to the keys.\nAdding \u003ccode\u003e**rest\u003c/code\u003e at the end of the pattern to capture extra items is allowed.\u003c/li\u003e\n\u003cli\u003eA \u003cstrong\u003eclass pattern\u003c/strong\u003e is similar to the above but matches attributes instead\nof keys. It looks like \u003ccode\u003edatetime.date(year=y, day=d)\u003c/code\u003e. It matches\ninstances of the given type, having at least the specified\nattributes, as long as the attributes match with the corresponding\nsub-patterns. It binds whatever the sub-patterns bind when matching with the\nvalues of\nthe given attributes. An optional protocol also allows matching positional\narguments.\u003c/li\u003e\n\u003cli\u003eAn \u003cstrong\u003eOR pattern\u003c/strong\u003e looks like \u003ccode\u003e[*x] | {\"elems\": [*x]}\u003c/code\u003e. It matches if any\nof its sub-patterns match. It uses the binding for the leftmost pattern\nthat matched.\u003c/li\u003e\n\u003cli\u003eA \u003cstrong\u003ewalrus pattern\u003c/strong\u003e looks like \u003ccode\u003ed := datetime(year=2020, month=m)\u003c/code\u003e. It\nmatches only\nif its sub-pattern also matches. It binds whatever the sub-pattern match does, and\nalso binds the named variable to the entire object.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-the-match-statement\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eThe \u003ccode\u003ematch\u003c/code\u003e statement\u003c/h3\u003e\u003ca id=\"user-content-the-match-statement\" class=\"anchor\" aria-label=\"Permalink: The match statement\" href=\"#the-match-statement\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA simplified, approximate grammar for the proposed syntax is:\u003c/p\u003e\n\u003cpre\u003e...\ncompound_statement:\n | if_stmt\n ...\n | match_stmt\nmatch_stmt: \"match\" expression ':' NEWLINE INDENT case_block+ DEDENT\ncase_block: \"case\" pattern [guard] ':' block\nguard: 'if' expression\npattern: walrus_pattern | or_pattern\nwalrus_pattern: NAME ':=' or_pattern\nor_pattern: closed_pattern ('|' closed_pattern)*\nclosed_pattern:\n | literal_pattern\n | capture_pattern\n | wildcard_pattern\n | constant_pattern\n | sequence_pattern\n | mapping_pattern\n | class_pattern\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eSee \u003ca href=\"#appendix-a-full-grammar\"\u003eAppendix A\u003c/a\u003e for the full, unabridged grammar.\nThe simplified grammars in this section are there for helping the reader,\nnot as a full specification.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe propose that the match operation should be a statement, not an expression.\nAlthough in\nmany languages it is an expression, being a statement better suits the general\nlogic of Python syntax. See \u003ca href=\"#rejected-ideas\"\u003erejected ideas\u003c/a\u003e for more discussion.\nThe allowed patterns are described in detail below in the \u003ca href=\"#allowed-patterns\"\u003epatterns\u003c/a\u003e subsection.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode\u003ematch\u003c/code\u003e and \u003ccode\u003ecase\u003c/code\u003e keywords are proposed to be soft keywords,\nso that they are recognized as keywords at the beginning of a match\nstatement or case block respectively, but are allowed to be used in\nother places as variable or argument names.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe proposed indentation structure is as following:\u003c/p\u003e\n\u003cpre\u003ematch some_expression:\n case pattern_1:\n ...\n case pattern_2:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eHere, \u003ccode\u003esome_expression\u003c/code\u003e represents the value that is being matched against,\nwhich will be referred to hereafter as the \u003cem\u003esubject\u003c/em\u003e of the match.\u003c/p\u003e\n\u003ca name=\"user-content-match-semantics\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMatch semantics\u003c/h3\u003e\u003ca id=\"user-content-match-semantics\" class=\"anchor\" aria-label=\"Permalink: Match semantics\" href=\"#match-semantics\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe proposed large scale semantics for choosing the match is to choose the first\nmatching pattern and execute the corresponding suite. The remaining patterns\nare not tried. If there are no matching patterns, the statement 'falls\nthrough', and execution continues at the following statement.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eEssentially this is equivalent to a chain of \u003ccode\u003eif ... elif ... else\u003c/code\u003e\nstatements. Note that unlike for the previously proposed \u003ccode\u003eswitch\u003c/code\u003e statement,\nthe pre-computed dispatch dictionary semantics does not apply here.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThere is no \u003ccode\u003edefault\u003c/code\u003e or \u003ccode\u003eelse\u003c/code\u003e case - instead the special wildcard\n\u003ccode\u003e_\u003c/code\u003e can be used (see the section on \u003ca href=\"#capture-patterns\"\u003ecapture_pattern\u003c/a\u003e)\nas a final 'catch-all' pattern.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eName bindings made during a successful pattern match outlive the executed suite\nand can be used after the match statement. This follows the logic of other\nPython statements that can bind names, such as \u003ccode\u003efor\u003c/code\u003e loop and \u003ccode\u003ewith\u003c/code\u003e\nstatement. For example:\u003c/p\u003e\n\u003cpre\u003ematch shape:\n case Point(x, y):\n ...\n case Rectangle(x, y, _, _):\n ...\nprint(x, y) # This works\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eDuring failed pattern matches, some sub-patterns may succeed. For example,\nwhile matching the value \u003ccode\u003e[0, 1, 2]\u003c/code\u003e with the pattern \u003ccode\u003e(0, x, 1)\u003c/code\u003e, the\nsub-pattern \u003ccode\u003ex\u003c/code\u003e may succeed if the list elements are matched from left to right.\nThe implementation may choose to either make persistent bindings for those\npartial matches or not. User code including a \u003ccode\u003ematch\u003c/code\u003e statement should not rely\non the bindings being made for a failed match, but also shouldn't assume that\nvariables are unchanged by a failed match. This part of the behavior is\nleft intentionally unspecified so different implementations can add\noptimizations, and to prevent introducing semantic restrictions that could\nlimit the extensibility of this feature.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that some pattern types below define more specific rules about when\nthe binding is made.\u003c/p\u003e\n\u003ca name=\"user-content-allowed-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAllowed patterns\u003c/h3\u003e\u003ca id=\"user-content-allowed-patterns\" class=\"anchor\" aria-label=\"Permalink: Allowed patterns\" href=\"#allowed-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWe introduce the proposed syntax gradually. Here we start from the main\nbuilding blocks. The following patterns are supported:\u003c/p\u003e\n\u003ca name=\"user-content-literal-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eLiteral Patterns\u003c/h4\u003e\u003ca id=\"user-content-literal-patterns\" class=\"anchor\" aria-label=\"Permalink: Literal Patterns\" href=\"#literal-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003eliteral_pattern:\n | number\n | string\n | 'None'\n | 'True'\n | 'False'\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eA literal pattern consists of a simple literal like a string, a number,\na Boolean literal (\u003ccode\u003eTrue\u003c/code\u003e or \u003ccode\u003eFalse\u003c/code\u003e), or \u003ccode\u003eNone\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003ematch number:\n case 0:\n print(\"Nothing\")\n case 1:\n print(\"Just one\")\n case 2:\n print(\"A couple\")\n case -1:\n print(\"One less than nothing\")\n case 1-1j:\n print(\"Good luck with that...\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eLiteral pattern uses equality with literal on the right hand side, so that\nin the above example \u003ccode\u003enumber == 0\u003c/code\u003e and then possibly \u003ccode\u003enumber == 1\u003c/code\u003e, etc\nwill be evaluated. Note that although technically negative numbers\nare represented using unary minus, they are considered\nliterals for the purpose of pattern matching. Unary plus is not allowed.\nBinary plus and minus are allowed only to join a real number and an imaginary\nnumber to form a complex number, such as \u003ccode\u003e1+1j\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that because equality (\u003ccode\u003e__eq__\u003c/code\u003e) is used, and the equivalency\nbetween Booleans and the integers \u003ccode\u003e0\u003c/code\u003e and \u003ccode\u003e1\u003c/code\u003e, there is no\npractical difference between the following two:\u003c/p\u003e\n\u003cpre\u003ecase True:\n ...\n\ncase 1:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eTriple-quoted strings are supported. Raw strings and byte strings\nare supported. F-strings are not allowed (since in general they are not\nreally literals).\u003c/p\u003e\n\u003ca name=\"user-content-capture-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCapture Patterns\u003c/h4\u003e\u003ca id=\"user-content-capture-patterns\" class=\"anchor\" aria-label=\"Permalink: Capture Patterns\" href=\"#capture-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003ecapture_pattern: NAME\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eA capture pattern serves as an assignment target for the matched expression:\u003c/p\u003e\n\u003cpre\u003ematch greeting:\n case \"\":\n print(\"Hello!\")\n case name:\n print(f\"Hi {name}!\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eOnly a single name is allowed (a dotted name is a constant value pattern).\nA capture pattern always succeeds. A capture pattern appearing in a scope makes\nthe name local to that scope. For example, using \u003ccode\u003ename\u003c/code\u003e after the above\nsnippet may raise \u003ccode\u003eUnboundLocalError\u003c/code\u003e rather than \u003ccode\u003eNameError\u003c/code\u003e, if\nthe \u003ccode\u003e\"\"\u003c/code\u003e case clause was taken:\u003c/p\u003e\n\u003cpre\u003ematch greeting:\n case \"\":\n print(\"Hello!\")\n case name:\n print(f\"Hi {name}!\")\nif name == \"Santa\": # \u0026lt;-- might raise UnboundLocalError\n ... # but works fine if greeting was not empty\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eWhile matching against each case clause, a name may be bound at most\nonce, having two capture patterns with coinciding names is an error:\u003c/p\u003e\n\u003cpre\u003ematch data:\n case [x, x]: # Error!\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eNote: one can still match on a collection with equal items using \u003ca href=\"#guards\"\u003eguards\u003c/a\u003e.\nAlso, \u003ccode\u003e[x, y] | Point(x, y)\u003c/code\u003e is a legal pattern because the two\nalternatives are never matched at the same time.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe single underscore (\u003ccode\u003e_\u003c/code\u003e) is not considered a \u003ccode\u003eNAME\u003c/code\u003e and treated specially\nas a \u003ca href=\"#wildcard-pattern\"\u003ewildcard pattern\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eReminder: \u003ccode\u003eNone\u003c/code\u003e, \u003ccode\u003eFalse\u003c/code\u003e and \u003ccode\u003eTrue\u003c/code\u003e are keywords denoting\nliterals, not names.\u003c/p\u003e\n\u003ca name=\"user-content-wildcard-pattern\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eWildcard Pattern\u003c/h4\u003e\u003ca id=\"user-content-wildcard-pattern\" class=\"anchor\" aria-label=\"Permalink: Wildcard Pattern\" href=\"#wildcard-pattern\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003ewildcard_pattern: \"_\"\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe single underscore (\u003ccode\u003e_\u003c/code\u003e) name is a special kind of pattern that always\nmatches but \u003cem\u003enever\u003c/em\u003e binds:\u003c/p\u003e\n\u003cpre\u003ematch data:\n case [_, _]:\n print(\"Some pair\")\n print(_) # Error!\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eGiven that no binding is made, it can be used as many times as desired, unlike\ncapture patterns.\u003c/p\u003e\n\u003ca name=\"user-content-constant-value-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eConstant Value Patterns\u003c/h4\u003e\u003ca id=\"user-content-constant-value-patterns\" class=\"anchor\" aria-label=\"Permalink: Constant Value Patterns\" href=\"#constant-value-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003econstant_pattern: NAME ('.' NAME)+\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis is used to match against constants and enum values.\nEvery dotted name in a pattern is looked up using normal Python name\nresolution rules, and the value is used for comparison by equality with\nthe match subject (same as for literals):\u003c/p\u003e\n\u003cpre\u003efrom enum import Enum\n\nclass Sides(str, Enum):\n SPAM = \"Spam\"\n EGGS = \"eggs\"\n ...\n\nmatch entree[-1]:\n case Sides.SPAM: # Compares entree[-1] == Sides.SPAM.\n response = \"Have you got anything without Spam?\"\n case side: # Assigns side = entree[-1].\n response = f\"Well, could I have their Spam instead of the {side} then?\"\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eNote that there is no way to use unqualified names as constant value\npatterns (they always denote variables to be captured). See\n\u003ca href=\"#rejected-ideas\"\u003erejected ideas\u003c/a\u003e for other syntactic alternatives that were\nconsidered for constant value patterns.\u003c/p\u003e\n\u003ca name=\"user-content-sequence-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSequence Patterns\u003c/h4\u003e\u003ca id=\"user-content-sequence-patterns\" class=\"anchor\" aria-label=\"Permalink: Sequence Patterns\" href=\"#sequence-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003esequence_pattern:\n | '[' [values_pattern] ']'\n | '(' [value_pattern ',' [values pattern]] ')'\nvalues_pattern: ','.value_pattern+ ','?\nvalue_pattern: '*' capture_pattern | pattern\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eA sequence pattern follows the same semantics as unpacking assignment.\nLike unpacking assignment, both tuple-like and list-like syntax can be\nused, with identical semantics. Each element can be an arbitrary\npattern; there may also be at most one \u003ccode\u003e*name\u003c/code\u003e pattern to catch all\nremaining items:\u003c/p\u003e\n\u003cpre\u003ematch collection:\n case 1, [x, *others]:\n print(\"Got 1 and a nested sequence\")\n case (1, x):\n print(f\"Got 1 and {x}\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eTo match a sequence pattern the subject must be an instance of\n\u003ccode\u003ecollections.abc.Sequence\u003c/code\u003e, and it cannot be any kind of string\n(\u003ccode\u003estr\u003c/code\u003e, \u003ccode\u003ebytes\u003c/code\u003e, \u003ccode\u003ebytearray\u003c/code\u003e). It cannot be an iterator. For matching\non a specific collection class, see class pattern below.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode\u003e_\u003c/code\u003e wildcard can be starred to match sequences of varying lengths. For\nexample:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003e[*_]\u003c/code\u003e matches a sequence of any length.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e(_, _, *_)\u003c/code\u003e, matches any sequence of length two or more.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e[\"a\", *_, \"z\"]\u003c/code\u003e matches any sequence of length two or more that starts with\n\u003ccode\u003e\"a\"\u003c/code\u003e and ends with \u003ccode\u003e\"z\"\u003c/code\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-mapping-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMapping Patterns\u003c/h4\u003e\u003ca id=\"user-content-mapping-patterns\" class=\"anchor\" aria-label=\"Permalink: Mapping Patterns\" href=\"#mapping-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003emapping_pattern: '{' [items_pattern] '}'\nitems_pattern: ','.key_value_pattern+ ','?\nkey_value_pattern:\n | (literal_pattern | constant_pattern) ':' or_pattern\n | '**' capture_pattern\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eMapping pattern is a generalization of iterable unpacking to mappings.\nIts syntax is similar to dictionary display but each key and value are\npatterns \u003ccode\u003e\"{\" (pattern \":\" pattern)+ \"}\"\u003c/code\u003e. A \u003ccode\u003e**rest\u003c/code\u003e pattern is also\nallowed, to extract the remaining items. Only literal and constant value\npatterns are allowed in key positions:\u003c/p\u003e\n\u003cpre\u003eimport constants\n\nmatch config:\n case {\"route\": route}:\n process_route(route)\n case {constants.DEFAULT_PORT: sub_config, **rest}:\n process_config(sub_config, rest)\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe subject must be an instance of \u003ccode\u003ecollections.abc.Mapping\u003c/code\u003e.\nExtra keys in the subject are ignored even if \u003ccode\u003e**rest\u003c/code\u003e is not present.\nThis is different from sequence pattern, where extra items will cause a\nmatch to fail. But mappings are actually different from sequences: they\nhave natural structural sub-typing behavior, i.e., passing a dictionary\nwith extra keys somewhere will likely just work.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor this reason, \u003ccode\u003e**_\u003c/code\u003e is invalid in mapping patterns; it would always be a\nno-op that could be removed without consequence.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eMatched key-value pairs must already be present in the mapping, and not created\non-the-fly by \u003ccode\u003e__missing__\u003c/code\u003e or \u003ccode\u003e__getitem__\u003c/code\u003e. For example,\n\u003ccode\u003ecollections.defaultdict\u003c/code\u003e instances will only match patterns with keys that\nwere already present when the \u003ccode\u003ematch\u003c/code\u003e block was entered.\u003c/p\u003e\n\u003ca name=\"user-content-class-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch4 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eClass Patterns\u003c/h4\u003e\u003ca id=\"user-content-class-patterns\" class=\"anchor\" aria-label=\"Permalink: Class Patterns\" href=\"#class-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eSimplified syntax:\u003c/p\u003e\n\u003cpre\u003eclass_pattern:\n | name_or_attr '(' ')'\n | name_or_attr '(' ','.pattern+ ','? ')'\n | name_or_attr '(' ','.keyword_pattern+ ','? ')'\n | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'\nkeyword_pattern: NAME '=' or_pattern\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eA class pattern provides support for destructuring arbitrary objects.\nThere are two possible ways of matching on object attributes: by position\nlike \u003ccode\u003ePoint(1, 2)\u003c/code\u003e, and by name like \u003ccode\u003ePoint(x=1, y=2)\u003c/code\u003e. These\ntwo can be combined, but a positional match cannot follow a match by name.\nEach item in a class pattern can be an arbitrary pattern. A simple\nexample:\u003c/p\u003e\n\u003cpre\u003ematch shape:\n case Point(x, y):\n ...\n case Rectangle(x0, y0, x1, y1, painted=True):\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eWhether a match succeeds or not is determined by the equivalent of an\n\u003ccode\u003eisinstance\u003c/code\u003e call. If the subject (\u003ccode\u003eshape\u003c/code\u003e, in the example) is not\nan instance of the named class (\u003ccode\u003ePoint\u003c/code\u003e or \u003ccode\u003eRectangle\u003c/code\u003e), the match\nfails. Otherwise, it continues (see details in the \u003ca href=\"#runtime-specification\"\u003eruntime\u003c/a\u003e section).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe named class must inherit from \u003ccode\u003etype\u003c/code\u003e. It may be a single name\nor a dotted name (e.g. \u003ccode\u003esome_mod.SomeClass\u003c/code\u003e or \u003ccode\u003emod.pkg.Class\u003c/code\u003e).\nThe leading name must not be \u003ccode\u003e_\u003c/code\u003e, so e.g. \u003ccode\u003e_(...)\u003c/code\u003e and\n\u003ccode\u003e_.C(...)\u003c/code\u003e are invalid. Use \u003ccode\u003eobject(foo=_)\u003c/code\u003e to check whether the\nmatched object has an attribute \u003ccode\u003efoo\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eBy default, sub-patterns may only be matched by keyword for\nuser-defined classes. In order to support positional sub-patterns, a\ncustom \u003ccode\u003e__match_args__\u003c/code\u003e attribute is required.\nThe runtime allows matching against\narbitrarily nested patterns by chaining all of the instance checks and\nattribute lookups appropriately.\u003c/p\u003e\n\u003ca name=\"user-content-combining-multiple-patterns-or-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCombining multiple patterns (OR patterns)\u003c/h3\u003e\u003ca id=\"user-content-combining-multiple-patterns-or-patterns\" class=\"anchor\" aria-label=\"Permalink: Combining multiple patterns (OR patterns)\" href=\"#combining-multiple-patterns-or-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eMultiple alternative patterns can be combined into one using \u003ccode\u003e|\u003c/code\u003e. This means\nthe whole pattern matches if at least one alternative matches.\nAlternatives are tried from left to right and have a short-circuit property,\nsubsequent patterns are not tried if one matched. Examples:\u003c/p\u003e\n\u003cpre\u003ematch something:\n case 0 | 1 | 2:\n print(\"Small number\")\n case [] | [_]:\n print(\"A short sequence\")\n case str() | bytes():\n print(\"Something string-like\")\n case _:\n print(\"Something else\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe alternatives may bind variables, as long as each alternative binds\nthe same set of variables (excluding \u003ccode\u003e_\u003c/code\u003e). For example:\u003c/p\u003e\n\u003cpre\u003ematch something:\n case 1 | x: # Error!\n ...\n case x | 1: # Error!\n ...\n case one := [1] | two := [2]: # Error!\n ...\n case Foo(arg=x) | Bar(arg=x): # Valid, both arms bind 'x'\n ...\n case [x] | x: # Valid, both arms bind 'x'\n ...\n\u003c/pre\u003e\n\u003ca name=\"user-content-guards\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eGuards\u003c/h3\u003e\u003ca id=\"user-content-guards\" class=\"anchor\" aria-label=\"Permalink: Guards\" href=\"#guards\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eEach \u003cem\u003etop-level\u003c/em\u003e pattern can be followed by a \u003cstrong\u003eguard\u003c/strong\u003e of the form\n\u003ccode\u003eif expression\u003c/code\u003e. A case clause succeeds if the pattern matches and the guard\nevaluates to a true value. For example:\u003c/p\u003e\n\u003cpre\u003ematch input:\n case [x, y] if x \u0026gt; MAX_INT and y \u0026gt; MAX_INT:\n print(\"Got a pair of large numbers\")\n case x if x \u0026gt; MAX_INT:\n print(\"Got a large number\")\n case [x, y] if x == y:\n print(\"Got equal items\")\n case _:\n print(\"Not an outstanding input\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eIf evaluating a guard raises an exception, it is propagated onwards rather\nthan fail the case clause. Names that appear in a pattern are bound before the\nguard succeeds. So this will work:\u003c/p\u003e\n\u003cpre\u003evalues = [0]\n\nmatch values:\n case [x] if x:\n ... # This is not executed\n case _:\n ...\nprint(x) # This will print \"0\"\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eNote that guards are not allowed for nested patterns, so that \u003ccode\u003e[x if x \u0026gt; 0]\u003c/code\u003e\nis a \u003ccode\u003eSyntaxError\u003c/code\u003e and \u003ccode\u003e1 | 2 if 3 | 4\u003c/code\u003e will be parsed as\n\u003ccode\u003e(1 | 2) if (3 | 4)\u003c/code\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-walrus-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eWalrus patterns\u003c/h3\u003e\u003ca id=\"user-content-walrus-patterns\" class=\"anchor\" aria-label=\"Permalink: Walrus patterns\" href=\"#walrus-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIt is often useful to match a sub-pattern \u003cem\u003eand\u003c/em\u003e bind the corresponding\nvalue to a name. For example, it can be useful to write more efficient\nmatches, or simply to avoid repetition. To simplify such cases, any pattern\n(other than the walrus pattern itself) can be preceded by a name and\nthe walrus operator (\u003ccode\u003e:=\u003c/code\u003e). For example:\u003c/p\u003e\n\u003cpre\u003ematch get_shape():\n case Line(start := Point(x, y), end) if start == end:\n print(f\"Zero length line at {x}, {y}\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe name on the left of the walrus operator can be used in a guard, in\nthe match suite, or after the match statement. However, the name will\n\u003cem\u003eonly\u003c/em\u003e be bound if the sub-pattern succeeds. Another example:\u003c/p\u003e\n\u003cpre\u003ematch group_shapes():\n case [], [point := Point(x, y), *other]:\n print(f\"Got {point} in the second group\")\n process_coordinates(x, y)\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eTechnically, most such examples can be rewritten using guards and/or nested\nmatch statements, but this will be less readable and/or will produce less\nefficient code. Essentially, most of the arguments in \u003ca href=\"http://www.python.org/dev/peps/pep-0572\" rel=\"nofollow\"\u003ePEP 572\u003c/a\u003e apply here\nequally.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe wildcard \u003ccode\u003e_\u003c/code\u003e is not a valid name here.\u003c/p\u003e\n\u003ca name=\"user-content-runtime-specification\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRuntime specification\u003c/h2\u003e\u003ca id=\"user-content-runtime-specification\" class=\"anchor\" aria-label=\"Permalink: Runtime specification\" href=\"#runtime-specification\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003ca name=\"user-content-the-match-protocol\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eThe Match Protocol\u003c/h3\u003e\u003ca id=\"user-content-the-match-protocol\" class=\"anchor\" aria-label=\"Permalink: The Match Protocol\" href=\"#the-match-protocol\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe equivalent of an \u003ccode\u003eisinstance\u003c/code\u003e call is used to decide whether an\nobject matches a given class pattern and to extract the corresponding\nattributes. Classes requiring different matching semantics (such as\nduck-typing) can do so by defining \u003ccode\u003e__instancecheck__\u003c/code\u003e (a\npre-existing metaclass hook) or by using \u003ccode\u003etyping.Protocol\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe procedure is as following:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eThe class object for \u003ccode\u003eClass\u003c/code\u003e in \u003ccode\u003eClass(\u0026lt;sub-patterns\u0026gt;)\u003c/code\u003e is\nlooked up and \u003ccode\u003eisinstance(obj, Class)\u003c/code\u003e is called, where \u003ccode\u003eobj\u003c/code\u003e is\nthe value being matched. If false, the match fails.\u003c/li\u003e\n\u003cli\u003eOtherwise, if any sub-patterns are given in the form of positional\nor keyword arguments, these are matched from left to right, as\nfollows. The match fails as soon as a sub-pattern fails; if all\nsub-patterns succeed, the overall class pattern match succeeds.\u003c/li\u003e\n\u003cli\u003eIf there are match-by-position items and the class has a\n\u003ccode\u003e__match_args__\u003c/code\u003e attribute, the item at position \u003ccode\u003ei\u003c/code\u003e\nis matched against the value looked up by attribute\n\u003ccode\u003e__match_args__[i]\u003c/code\u003e. For example, a pattern \u003ccode\u003ePoint2d(5, 8)\u003c/code\u003e,\nwhere \u003ccode\u003ePoint2d.__match_args__ == [\"x\", \"y\"]\u003c/code\u003e, is translated\n(approximately) into \u003ccode\u003eobj.x == 5 and obj.y == 8\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003eIf there are more positional items than the length of\n\u003ccode\u003e__match_args__\u003c/code\u003e, a \u003ccode\u003eTypeError\u003c/code\u003e is raised.\u003c/li\u003e\n\u003cli\u003eIf the \u003ccode\u003e__match_args__\u003c/code\u003e attribute is absent on the matched class,\nand one or more positional item appears in a match,\n\u003ccode\u003eTypeError\u003c/code\u003e is also raised. We don't fall back on\nusing \u003ccode\u003e__slots__\u003c/code\u003e or \u003ccode\u003e__annotations__\u003c/code\u003e -- \"In the face of ambiguity,\nrefuse the temptation to guess.\"\u003c/li\u003e\n\u003cli\u003eIf there are any match-by-keyword items the keywords are looked up\nas attributes on the subject. If the lookup succeeds the value is\nmatched against the corresponding sub-pattern. If the lookup fails,\nthe match fails.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eSuch a protocol favors simplicity of implementation over flexibility and\nperformance. For other considered alternatives, see \u003ca href=\"#extended-matching\"\u003eextended matching\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor the most commonly-matched built-in types (\u003ccode\u003ebool\u003c/code\u003e,\n\u003ccode\u003ebytearray\u003c/code\u003e, \u003ccode\u003ebytes\u003c/code\u003e, \u003ccode\u003edict\u003c/code\u003e, \u003ccode\u003efloat\u003c/code\u003e,\n\u003ccode\u003efrozenset\u003c/code\u003e, \u003ccode\u003eint\u003c/code\u003e, \u003ccode\u003elist\u003c/code\u003e, \u003ccode\u003eset\u003c/code\u003e, \u003ccode\u003estr\u003c/code\u003e, and \u003ccode\u003etuple\u003c/code\u003e), a\nsingle positional sub-pattern is allowed to be passed to\nthe call. Rather than being matched against any particular attribute\non the subject, it is instead matched against the subject itself. This\ncreates behavior that is useful and intuitive for these objects:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003ebool(False)\u003c/code\u003e matches \u003ccode\u003eFalse\u003c/code\u003e (but not \u003ccode\u003e0\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003etuple((0, 1, 2))\u003c/code\u003e matches \u003ccode\u003e(0, 1, 2)\u003c/code\u003e (but not \u003ccode\u003e[0, 1, 2]\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eint(i)\u003c/code\u003e matches any \u003ccode\u003eint\u003c/code\u003e and binds it to the name \u003ccode\u003ei\u003c/code\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-overlapping-sub-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eOverlapping sub-patterns\u003c/h3\u003e\u003ca id=\"user-content-overlapping-sub-patterns\" class=\"anchor\" aria-label=\"Permalink: Overlapping sub-patterns\" href=\"#overlapping-sub-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eCertain classes of overlapping matches are detected at\nruntime and will raise exceptions. In addition to basic checks\ndescribed in the previous subsection:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eThe interpreter will check that two match items are not targeting the same\nattribute, for example \u003ccode\u003ePoint2d(1, 2, y=3)\u003c/code\u003e is an error.\u003c/li\u003e\n\u003cli\u003eIt will also check that a mapping pattern does not attempt to match\nthe same key more than once.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-special-attribute-match-args\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSpecial attribute \u003ccode\u003e__match_args__\u003c/code\u003e\u003c/h3\u003e\u003ca id=\"user-content-special-attribute-__match_args__\" class=\"anchor\" aria-label=\"Permalink: Special attribute __match_args__\" href=\"#special-attribute-__match_args__\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode\u003e__match_args__\u003c/code\u003e attribute is always looked up on the type\nobject named in the pattern. If present, it must be a list or tuple\nof strings naming the allowed positional arguments.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn deciding what names should be available for matching, the\nrecommended practice is that class patterns should be the mirror of\nconstruction; that is, the set of available names and their types\nshould resemble the arguments to \u003ccode\u003e__init__()\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eOnly match-by-name will work by default, and classes should define\n\u003ccode\u003e__match_args__\u003c/code\u003e as a class attribute if they would like to support\nmatch-by-position. Additionally, dataclasses and named tuples will\nsupport match-by-position out of the box. See below for more details.\u003c/p\u003e\n\u003ca name=\"user-content-exceptions-and-side-effects\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExceptions and side effects\u003c/h3\u003e\u003ca id=\"user-content-exceptions-and-side-effects\" class=\"anchor\" aria-label=\"Permalink: Exceptions and side effects\" href=\"#exceptions-and-side-effects\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWhile matching each case, the \u003ccode\u003ematch\u003c/code\u003e statement may trigger execution of other\nfunctions (for example \u003ccode\u003e__getitem__()\u003c/code\u003e, \u003ccode\u003e__len__()\u003c/code\u003e or\na property). Almost every exception caused by those propagates outside of the\nmatch statement normally. The only case where an exception is not propagated is\nan \u003ccode\u003eAttributeError\u003c/code\u003e raised while trying to lookup an attribute while matching\nattributes of a Class Pattern; that case results in just a matching failure,\nand the rest of the statement proceeds normally.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe only side-effect carried on explicitly by the matching process is the binding of\nnames. However, the process relies on attribute access,\ninstance checks, \u003ccode\u003elen()\u003c/code\u003e, equality and item access on the subject and some of\nits components. It also evaluates constant value patterns and the left side of\nclass patterns. While none of those typically create any side-effects, some of\nthese objects could. This proposal intentionally leaves out any specification\nof what methods are called or how many times. User code relying on that\nbehavior should be considered buggy.\u003c/p\u003e\n\u003ca name=\"user-content-the-standard-library\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eThe standard library\u003c/h3\u003e\u003ca id=\"user-content-the-standard-library\" class=\"anchor\" aria-label=\"Permalink: The standard library\" href=\"#the-standard-library\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTo facilitate the use of pattern matching, several changes will be made to\nthe standard library:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eNamedtuples and dataclasses will have auto-generated \u003ccode\u003e__match_args__\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003eFor dataclasses the order of attributes in the generated \u003ccode\u003e__match_args__\u003c/code\u003e\nwill be the same as the order of corresponding arguments in the generated\n\u003ccode\u003e__init__()\u003c/code\u003e method. This includes the situations where attributes are\ninherited from a superclass.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eIn addition, a systematic effort will be put into going through\nexisting standard library classes and adding \u003ccode\u003e__match_args__\u003c/code\u003e where\nit looks beneficial.\u003c/p\u003e\n\u003ca name=\"user-content-static-checkers-specification\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eStatic checkers specification\u003c/h2\u003e\u003ca id=\"user-content-static-checkers-specification\" class=\"anchor\" aria-label=\"Permalink: Static checkers specification\" href=\"#static-checkers-specification\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003ca name=\"user-content-exhaustiveness-checks\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExhaustiveness checks\u003c/h3\u003e\u003ca id=\"user-content-exhaustiveness-checks\" class=\"anchor\" aria-label=\"Permalink: Exhaustiveness checks\" href=\"#exhaustiveness-checks\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFrom a reliability perspective, experience shows that missing a case when\ndealing with a set of possible data values leads to hard to debug issues,\nthus forcing people to add safety asserts like this:\u003c/p\u003e\n\u003cpre\u003edef get_first(data: Union[int, list[int]]) -\u0026gt; int:\n if isinstance(data, list) and data:\n return data[0]\n elif isinstance(data, int):\n return data\n else:\n assert False, \"should never get here\"\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"http://www.python.org/dev/peps/pep-0484\" rel=\"nofollow\"\u003ePEP 484\u003c/a\u003e specifies that static type checkers should support exhaustiveness in\nconditional checks with respect to enum values. \u003ca href=\"http://www.python.org/dev/peps/pep-0586\" rel=\"nofollow\"\u003ePEP 586\u003c/a\u003e later generalized this\nrequirement to literal types.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis PEP further generalizes this requirement to\narbitrary patterns. A typical situation where this applies is matching an\nexpression with a union type:\u003c/p\u003e\n\u003cpre\u003edef classify(val: Union[int, Tuple[int, int], List[int]]) -\u0026gt; str:\n match val:\n case [x, y] if x \u0026gt; 0 and y \u0026gt; 0:\n return f\"A pair of {x} and {y}\"\n case [x, *other]:\n return f\"A sequence starting with {x}\"\n case int():\n return f\"Some integer\"\n # Type-checking error: some cases unhandled.\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe exhaustiveness checks should also apply where both pattern matching\nand enum values are combined:\u003c/p\u003e\n\u003cpre\u003efrom enum import Enum\nfrom typing import Union\n\nclass Level(Enum):\n BASIC = 1\n ADVANCED = 2\n PRO = 3\n\nclass User:\n name: str\n level: Level\n\nclass Admin:\n name: str\n\naccount: Union[User, Admin]\n\nmatch account:\n case Admin(name=name) | User(name=name, level=Level.PRO):\n ...\n case User(level=Level.ADVANCED):\n ...\n # Type-checking error: basic user unhandled\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eObviously, no \u003ccode\u003eMatchable\u003c/code\u003e protocol (in terms of \u003ca href=\"http://www.python.org/dev/peps/pep-0544\" rel=\"nofollow\"\u003ePEP 544\u003c/a\u003e) is needed, since\nevery class is matchable and therefore is subject to the checks specified\nabove.\u003c/p\u003e\n\u003ca name=\"user-content-sealed-classes-as-algebraic-data-types\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eSealed classes as algebraic data types\u003c/h3\u003e\u003ca id=\"user-content-sealed-classes-as-algebraic-data-types\" class=\"anchor\" aria-label=\"Permalink: Sealed classes as algebraic data types\" href=\"#sealed-classes-as-algebraic-data-types\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eQuite often it is desirable to apply exhaustiveness to a set of classes without\ndefining ad-hoc union types, which is itself fragile if a class is missing in\nthe union definition. A design pattern where a group of record-like classes is\ncombined into a union is popular in other languages that support pattern\nmatching and is known under a name of \u003ca href=\"https://en.wikipedia.org/wiki/Algebraic_data_type\" rel=\"nofollow\"\u003ealgebraic data types\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe propose to add a special decorator class \u003ccode\u003e@sealed\u003c/code\u003e to the \u003ca href=\"#id2\"\u003e\u003cspan id=\"user-content-id3\"\u003e:py:mod:`typing`\u003c/span\u003e\u003c/a\u003e\nmodule, that will have no effect at runtime, but will indicate to static\ntype checkers that all subclasses (direct and indirect) of this class should\nbe defined in the same module as the base class.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe idea is that since all subclasses are known, the type checker can treat\nthe sealed base class as a union of all its subclasses. Together with\ndataclasses this allows a clean and safe support of algebraic data types\nin Python. Consider this example:\u003c/p\u003e\n\u003cpre\u003efrom dataclasses import dataclass\nfrom typing import sealed\n\n@sealed\nclass Node:\n ...\n\nclass Expression(Node):\n ...\n\nclass Statement(Node):\n ...\n\n@dataclass\nclass Name(Expression):\n name: str\n\n@dataclass\nclass Operation(Expression):\n left: Expression\n op: str\n right: Expression\n\n@dataclass\nclass Assignment(Statement):\n target: str\n value: Expression\n\n@dataclass\nclass Print(Statement):\n value: Expression\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eWith such definition, a type checker can safely treat \u003ccode\u003eNode\u003c/code\u003e as\n\u003ccode\u003eUnion[Name, Operation, Assignment, Print]\u003c/code\u003e, and also safely treat e.g.\n\u003ccode\u003eExpression\u003c/code\u003e as \u003ccode\u003eUnion[Name, Operation]\u003c/code\u003e. So this will result in a type\nchecking error in the below snippet, because \u003ccode\u003eName\u003c/code\u003e is not handled (and type\nchecker can give a useful error message):\u003c/p\u003e\n\u003cpre\u003edef dump(node: Node) -\u0026gt; str:\n match node:\n case Assignment(target, value):\n return f\"{target} = {dump(value)}\"\n case Print(value):\n return f\"print({dump(value)})\"\n case Operation(left, op, right):\n return f\"({dump(left)} {op} {dump(right)})\"\n\u003c/pre\u003e\n\u003ca name=\"user-content-type-erasure\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eType erasure\u003c/h3\u003e\u003ca id=\"user-content-type-erasure\" class=\"anchor\" aria-label=\"Permalink: Type erasure\" href=\"#type-erasure\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eClass patterns are subject to runtime type erasure. Namely, although one\ncan define a type alias \u003ccode\u003eIntQueue = Queue[int]\u003c/code\u003e so that a pattern like\n\u003ccode\u003eIntQueue()\u003c/code\u003e is syntactically valid, type checkers should reject such a\nmatch:\u003c/p\u003e\n\u003cpre\u003equeue: Union[Queue[int], Queue[str]]\nmatch queue:\n case IntQueue(): # Type-checking error here\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eNote that the above snippet actually fails at runtime with the current\nimplementation of generic classes in the \u003ccode\u003etyping\u003c/code\u003e module, as well as\nwith builtin generic classes in the recently accepted \u003ca href=\"http://www.python.org/dev/peps/pep-0585\" rel=\"nofollow\"\u003ePEP 585\u003c/a\u003e, because\nthey prohibit \u003ccode\u003eisinstance\u003c/code\u003e checks.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eTo clarify, generic classes are not prohibited in general from participating\nin pattern matching, just that their type parameters can't be explicitly\nspecified. It is still fine if sub-patterns or literals bind the type\nvariables. For example:\u003c/p\u003e\n\u003cpre\u003efrom typing import Generic, TypeVar, Union\n\nT = TypeVar('T')\n\nclass Result(Generic[T]):\n first: T\n other: list[T]\n\nresult: Union[Result[int], Result[str]]\n\nmatch result:\n case Result(first=int()):\n ... # Type of result is Result[int] here\n case Result(other=[\"foo\", \"bar\", *rest]):\n ... # Type of result is Result[str] here\n\u003c/pre\u003e\n\u003ca name=\"user-content-note-about-constants\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eNote about constants\u003c/h3\u003e\u003ca id=\"user-content-note-about-constants\" class=\"anchor\" aria-label=\"Permalink: Note about constants\" href=\"#note-about-constants\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe fact that a capture pattern is always an assignment target may create unwanted\nconsequences when a user by mistake tries to \"match\" a value against\na constant instead of using the constant value pattern. As a result, at\nruntime such a match will always succeed and moreover override the value of\nthe constant. It is important therefore that static type checkers warn about\nsuch situations. For example:\u003c/p\u003e\n\u003cpre\u003efrom typing import Final\n\nMAX_INT: Final = 2 ** 64\n\nvalue = 0\n\nmatch value:\n case MAX_INT: # Type-checking error here: cannot assign to final name\n print(\"Got big number\")\n case _:\n print(\"Something else\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eNote that the CPython reference implementation also generates a\n\u003ccode\u003eSyntaxWarning\u003c/code\u003e message for this case.\u003c/p\u003e\n\u003ca name=\"user-content-precise-type-checking-of-star-matches\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePrecise type checking of star matches\u003c/h3\u003e\u003ca id=\"user-content-precise-type-checking-of-star-matches\" class=\"anchor\" aria-label=\"Permalink: Precise type checking of star matches\" href=\"#precise-type-checking-of-star-matches\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eType checkers should perform precise type checking of star items in pattern\nmatching giving them either a heterogeneous \u003ccode\u003elist[T]\u003c/code\u003e type, or\na \u003ccode\u003eTypedDict\u003c/code\u003e type as specified by \u003ca href=\"http://www.python.org/dev/peps/pep-0589\" rel=\"nofollow\"\u003ePEP 589\u003c/a\u003e. For example:\u003c/p\u003e\n\u003cpre\u003estuff: Tuple[int, str, str, float]\n\nmatch stuff:\n case a, *b, 0.5:\n # Here a is int and b is list[str]\n ...\n\u003c/pre\u003e\n\u003ca name=\"user-content-performance-considerations\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePerformance Considerations\u003c/h2\u003e\u003ca id=\"user-content-performance-considerations\" class=\"anchor\" aria-label=\"Permalink: Performance Considerations\" href=\"#performance-considerations\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIdeally, a \u003ccode\u003ematch\u003c/code\u003e statement should have good runtime performance compared\nto an equivalent chain of if-statements. Although the history of programming\nlanguages is rife with examples of new features which increased engineer\nproductivity at the expense of additional CPU cycles, it would be\nunfortunate if the benefits of \u003ccode\u003ematch\u003c/code\u003e were counter-balanced by a significant\noverall decrease in runtime performance.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAlthough this PEP does not specify any particular implementation strategy,\na few words about the prototype implementation and how it attempts to\nmaximize performance are in order.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eBasically, the prototype implementation transforms all of the \u003ccode\u003ematch\u003c/code\u003e\nstatement syntax into equivalent if/else blocks - or more accurately, into\nPython byte codes that have the same effect. In other words, all of the\nlogic for testing instance types, sequence lengths, mapping keys and\nso on are inlined in place of the \u003ccode\u003ematch\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis is not the only possible strategy, nor is it necessarily the best.\nFor example, the instance checks could be memoized, especially\nif there are multiple instances of the same class type but with different\narguments in a single match statement. It is also theoretically\npossible for a future implementation to process case clauses or sub-patterns in\nparallel using a decision tree rather than testing them one by one.\u003c/p\u003e\n\u003ca name=\"user-content-backwards-compatibility\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eBackwards Compatibility\u003c/h2\u003e\u003ca id=\"user-content-backwards-compatibility\" class=\"anchor\" aria-label=\"Permalink: Backwards Compatibility\" href=\"#backwards-compatibility\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis PEP is fully backwards compatible: the \u003ccode\u003ematch\u003c/code\u003e and \u003ccode\u003ecase\u003c/code\u003e\nkeywords are proposed to be (and stay!) soft keywords, so their use as\nvariable, function, class, module or attribute names is not impeded at\nall.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis is important because \u003ccode\u003ematch\u003c/code\u003e is the name of a popular and\nwell-known function and method in the \u003ccode\u003ere\u003c/code\u003e module, which we have no\ndesire to break or deprecate.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe difference between hard and soft keywords is that hard keywords\nare \u003cem\u003ealways\u003c/em\u003e reserved words, even in positions where they make no\nsense (e.g. \u003ccode\u003ex = class + 1\u003c/code\u003e), while soft keywords only get a special\nmeaning in context. Since \u003ca href=\"http://www.python.org/dev/peps/pep-0617\" rel=\"nofollow\"\u003ePEP 617\u003c/a\u003e the parser backtracks, that means that on\ndifferent attempts to parse a code fragment it could interpret a soft\nkeyword differently.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor example, suppose the parser encounters the following input:\u003c/p\u003e\n\u003cpre\u003ematch [x, y]:\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe parser first attempts to parse this as an expression statement.\nIt interprets \u003ccode\u003ematch\u003c/code\u003e as a NAME token, and then considers \u003ccode\u003e[x,\ny]\u003c/code\u003e to be a double subscript. It then encounters the colon and has\nto backtrack, since an expression statement cannot be followed by a\ncolon. The parser then backtracks to the start of the line and finds\nthat \u003ccode\u003ematch\u003c/code\u003e is a soft keyword allowed in this position. It then\nconsiders \u003ccode\u003e[x, y]\u003c/code\u003e to be a list expression. The colon then is just\nwhat the parser expected, and the parse succeeds.\u003c/p\u003e\n\u003ca name=\"user-content-impacts-on-third-party-tools\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eImpacts on third-party tools\u003c/h2\u003e\u003ca id=\"user-content-impacts-on-third-party-tools\" class=\"anchor\" aria-label=\"Permalink: Impacts on third-party tools\" href=\"#impacts-on-third-party-tools\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThere are a lot of tools in the Python ecosystem that operate on Python\nsource code: linters, syntax highlighters, auto-formatters, and IDEs. These\nwill all need to be updated to include awareness of the \u003ccode\u003ematch\u003c/code\u003e statement.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn general, these tools fall into one of two categories:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eShallow\u003c/strong\u003e parsers don't try to understand the full syntax of Python, but\ninstead scan the source code for specific known patterns. IDEs, such as Visual\nStudio Code, Emacs and TextMate, tend to fall in this category, since frequently\nthe source code is invalid while being edited, and a strict approach to parsing\nwould fail.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor these kinds of tools, adding knowledge of a new keyword is relatively\neasy, just an addition to a table, or perhaps modification of a regular\nexpression.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eDeep\u003c/strong\u003e parsers understand the complete syntax of Python. An example of this\nis the auto-formatter \u003ca href=\"https://black.readthedocs.io/en/stable/\" rel=\"nofollow\"\u003eBlack\u003c/a\u003e. A particular requirement with these kinds of\ntools is that they not only need to understand the syntax of the current version\nof Python, but older versions of Python as well.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode\u003ematch\u003c/code\u003e statement uses a soft keyword, and it is one of the first major\nPython features to take advantage of the capabilities of the new PEG parser. This\nmeans that third-party parsers which are not 'PEG-compatible' will have a hard\ntime with the new syntax.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIt has been noted that a number of these third-party tools leverage common parsing\nlibraries (Black for example uses a fork of the lib2to3 parser). It may be helpful\nto identify widely used parsing libraries (such as \u003ca href=\"https://github.com/davidhalter/parso\"\u003eparso\u003c/a\u003e and \u003ca href=\"https://github.com/Instagram/LibCST\"\u003elibCST\u003c/a\u003e)\nand upgrade them to be PEG compatible.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHowever, since this work would need to be done not only for the match statement,\nbut for \u003cem\u003eany\u003c/em\u003e new Python syntax that leverages the capabilities of the PEG parser,\nit is considered out of scope for this PEP. (Although it is suggested that this\nwould make a fine Summer of Code project.)\u003c/p\u003e\n\u003ca name=\"user-content-reference-implementation\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eReference Implementation\u003c/h2\u003e\u003ca id=\"user-content-reference-implementation\" class=\"anchor\" aria-label=\"Permalink: Reference Implementation\" href=\"#reference-implementation\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA \u003ca href=\"https://github.com/brandtbucher/cpython/tree/patma\"\u003efeature-complete CPython implementation\u003c/a\u003e is available on\nGitHub.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAn \u003ca href=\"https://mybinder.org/v2/gh/gvanrossum/patma/master?urlpath=lab/tree/playground-622.ipynb\" rel=\"nofollow\"\u003einteractive playground\u003c/a\u003e\nbased on the above implementation was created using \u003ca href=\"https://mybinder.org\" rel=\"nofollow\"\u003eBinder\u003c/a\u003e and \u003ca href=\"https://jupyter.org\" rel=\"nofollow\"\u003eJupyter\u003c/a\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-example-code\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExample Code\u003c/h2\u003e\u003ca id=\"user-content-example-code\" class=\"anchor\" aria-label=\"Permalink: Example Code\" href=\"#example-code\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA small \u003ca href=\"https://github.com/gvanrossum/patma/tree/master/examples\"\u003ecollection of example code\u003c/a\u003e is\navailable on GitHub.\u003c/p\u003e\n\u003ca name=\"user-content-rejected-ideas\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRejected Ideas\u003c/h2\u003e\u003ca id=\"user-content-rejected-ideas\" class=\"anchor\" aria-label=\"Permalink: Rejected Ideas\" href=\"#rejected-ideas\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis general idea has been floating around for a pretty long time, and many\nback and forth decisions were made. Here we summarize many alternative\npaths that were taken but eventually abandoned.\u003c/p\u003e\n\u003ca name=\"user-content-don-t-do-this-pattern-matching-is-hard-to-learn\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDon't do this, pattern matching is hard to learn\u003c/h3\u003e\u003ca id=\"user-content-dont-do-this-pattern-matching-is-hard-to-learn\" class=\"anchor\" aria-label=\"Permalink: Don't do this, pattern matching is hard to learn\" href=\"#dont-do-this-pattern-matching-is-hard-to-learn\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIn our opinion, the proposed pattern matching is not more difficult than\nadding \u003ccode\u003eisinstance()\u003c/code\u003e and \u003ccode\u003egetattr()\u003c/code\u003e to iterable unpacking. Also, we\nbelieve the proposed syntax significantly improves readability for a wide\nrange of code patterns, by allowing to express \u003cem\u003ewhat\u003c/em\u003e one wants to do, rather\nthan \u003cem\u003ehow\u003c/em\u003e to do it. We hope the few real code snippets we included in the PEP\nabove illustrate this comparison well enough. For more real code examples\nand their translations see Ref. \u003ca href=\"#id5\" id=\"user-content-id4\"\u003e[1]\u003c/a\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-don-t-do-this-use-existing-method-dispatching-mechanisms\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDon't do this, use existing method dispatching mechanisms\u003c/h3\u003e\u003ca id=\"user-content-dont-do-this-use-existing-method-dispatching-mechanisms\" class=\"anchor\" aria-label=\"Permalink: Don't do this, use existing method dispatching mechanisms\" href=\"#dont-do-this-use-existing-method-dispatching-mechanisms\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWe recognize that some of the use cases for the \u003ccode\u003ematch\u003c/code\u003e statement overlap\nwith what can be done with traditional object-oriented programming (OOP) design\ntechniques using class inheritance. The ability to choose alternate\nbehaviors based on testing the runtime type of a match subject might\neven seem heretical to strict OOP purists.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHowever, Python has always been a language that embraces a variety of\nprogramming styles and paradigms. Classic Python design idioms such as\n\"duck\"-typing go beyond the traditional OOP model.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe believe that there are important use cases where the use of \u003ccode\u003ematch\u003c/code\u003e results\nin a cleaner and more maintainable architecture. These use cases tend to\nbe characterized by a number of features:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eAlgorithms which cut across traditional lines of data encapsulation. If an\nalgorithm is processing heterogeneous elements of different types (such as\nevaluating or transforming an abstract syntax tree, or doing algebraic\nmanipulation of mathematical symbols), forcing the user to implement\nthe algorithm as individual methods on each element type results in\nlogic that is smeared across the entire codebase instead of being neatly\nlocalized in one place.\u003c/li\u003e\n\u003cli\u003eProgram architectures where the set of possible data types is relatively\nstable, but there is an ever-expanding set of operations to be performed\non those data types. Doing this in a strict OOP fashion requires constantly\nadding new methods to both the base class and subclasses to support the new\nmethods, \"polluting\" the base class with lots of very specialized method\ndefinitions, and causing widespread disruption and churn in the code. By\ncontrast, in a \u003ccode\u003ematch\u003c/code\u003e-based dispatch, adding a new behavior merely\ninvolves writing a new \u003ccode\u003ematch\u003c/code\u003e statement.\u003c/li\u003e\n\u003cli\u003eOOP also does not handle dispatching based on the \u003cem\u003eshape\u003c/em\u003e of an object, such\nas the length of a tuple, or the presence of an attribute -- instead any such\ndispatching decision must be encoded into the object's type. Shape-based\ndispatching is particularly interesting when it comes to handling \"duck\"-typed\nobjects.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eWhere OOP is clearly superior is in the opposite case: where the set of possible\noperations is relatively stable and well-defined, but there is an ever-growing\nset of data types to operate on. A classic example of this is UI widget toolkits,\nwhere there is a fixed set of interaction types (repaint, mouse click, keypress,\nand so on), but the set of widget types is constantly expanding as developers\ninvent new and creative user interaction styles. Adding a new kind of widget\nis a simple matter of writing a new subclass, whereas with a match-based approach\nyou end up having to add a new case clause to many widespread match statements.\nWe therefore don't recommend using \u003ccode\u003ematch\u003c/code\u003e in such a situation.\u003c/p\u003e\n\u003ca name=\"user-content-allow-more-flexible-assignment-targets-instead\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAllow more flexible assignment targets instead\u003c/h3\u003e\u003ca id=\"user-content-allow-more-flexible-assignment-targets-instead\" class=\"anchor\" aria-label=\"Permalink: Allow more flexible assignment targets instead\" href=\"#allow-more-flexible-assignment-targets-instead\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThere was an idea to instead just generalize the iterable unpacking to much\nmore general assignment targets, instead of adding a new kind of statement.\nThis concept is known in some other languages as \"irrefutable matches\". We\ndecided not to do this because inspection of real-life potential use cases\nshowed that in vast majority of cases destructuring is related to an \u003ccode\u003eif\u003c/code\u003e\ncondition. Also many of those are grouped in a series of exclusive choices.\u003c/p\u003e\n\u003ca name=\"user-content-make-it-an-expression\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMake it an expression\u003c/h3\u003e\u003ca id=\"user-content-make-it-an-expression\" class=\"anchor\" aria-label=\"Permalink: Make it an expression\" href=\"#make-it-an-expression\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIn most other languages pattern matching is represented by an expression, not\nstatement. But making it an expression would be inconsistent with other\nsyntactic choices in Python. All decision making logic is expressed almost\nexclusively in statements, so we decided to not deviate from this.\u003c/p\u003e\n\u003ca name=\"user-content-use-a-hard-keyword\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse a hard keyword\u003c/h3\u003e\u003ca id=\"user-content-use-a-hard-keyword\" class=\"anchor\" aria-label=\"Permalink: Use a hard keyword\" href=\"#use-a-hard-keyword\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThere were options to make \u003ccode\u003ematch\u003c/code\u003e a hard keyword, or choose a different\nkeyword. Although using a hard keyword would simplify life for simple-minded\nsyntax highlighters, we decided not to use hard keyword for several reasons:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eMost importantly, the new parser doesn't require us to do this. Unlike with\n\u003ccode\u003easync\u003c/code\u003e that caused hardships with being a soft keyword for few releases,\nhere we can make \u003ccode\u003ematch\u003c/code\u003e a permanent soft keyword.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ematch\u003c/code\u003e is so commonly used in existing code, that it would break almost\nevery existing program and will put a burden to fix code on many people who\nmay not even benefit from the new syntax.\u003c/li\u003e\n\u003cli\u003eIt is hard to find an alternative keyword that would not be commonly used\nin existing programs as an identifier, and would still clearly reflect the\nmeaning of the statement.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-use-as-or-instead-of-case-for-case-clauses\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse \u003ccode\u003eas\u003c/code\u003e or \u003ccode\u003e|\u003c/code\u003e instead of \u003ccode\u003ecase\u003c/code\u003e for case clauses\u003c/h3\u003e\u003ca id=\"user-content-use-as-or--instead-of-case-for-case-clauses\" class=\"anchor\" aria-label=\"Permalink: Use as or | instead of case for case clauses\" href=\"#use-as-or--instead-of-case-for-case-clauses\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe pattern matching proposed here is a combination of multi-branch control\nflow (in line with \u003ccode\u003eswitch\u003c/code\u003e in Algol-derived languages or \u003ccode\u003econd\u003c/code\u003e in Lisp)\nand object-deconstruction as found in functional languages. While the proposed\nkeyword \u003ccode\u003ecase\u003c/code\u003e highlights the multi-branch aspect, alternative keywords such\nas \u003ccode\u003eas\u003c/code\u003e would equally be possible, highlighting the deconstruction aspect.\n\u003ccode\u003eas\u003c/code\u003e or \u003ccode\u003ewith\u003c/code\u003e, for instance, also have the advantage of already being\nkeywords in Python. However, since \u003ccode\u003ecase\u003c/code\u003e as a keyword can only occur as a\nleading keyword inside a \u003ccode\u003ematch\u003c/code\u003e statement, it is easy for a parser to\ndistinguish between its use as a keyword or as a variable.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eOther variants would use a symbol like \u003ccode\u003e|\u003c/code\u003e or \u003ccode\u003e=\u0026gt;\u003c/code\u003e, or go entirely without\nspecial marker.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eSince Python is a statement-oriented language in the tradition of Algol, and as\neach composite statement starts with an identifying keyword, \u003ccode\u003ecase\u003c/code\u003e seemed to\nbe most in line with Python's style and traditions.\u003c/p\u003e\n\u003ca name=\"user-content-use-a-flat-indentation-scheme\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse a flat indentation scheme\u003c/h3\u003e\u003ca id=\"user-content-use-a-flat-indentation-scheme\" class=\"anchor\" aria-label=\"Permalink: Use a flat indentation scheme\" href=\"#use-a-flat-indentation-scheme\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThere was an idea to use an alternative indentation scheme, for example where\nevery case clause would not be indented with respect to the initial \u003ccode\u003ematch\u003c/code\u003e\npart:\u003c/p\u003e\n\u003cpre\u003ematch expression:\ncase pattern_1:\n ...\ncase pattern_2:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe motivation is that although flat indentation saves some horizontal space,\nit may look awkward to an eye of a Python programmer, because everywhere else\ncolon is followed by an indent. This will also complicate life for\nsimple-minded code editors. Finally, the horizontal space issue can be\nalleviated by allowing \"half-indent\" (i.e. two spaces instead of four) for\nmatch statements.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn sample programs using \u003ccode\u003ematch\u003c/code\u003e, written as part of the development of this\nPEP, a noticeable improvement in code brevity is observed, more than making up\nfor the additional indentation level.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAnother proposal considered was to use flat indentation but put the\nexpression on the line after \u003ccode\u003ematch:\u003c/code\u003e, like this:\u003c/p\u003e\n\u003cpre\u003ematch:\n expression\ncase pattern_1:\n ...\ncase pattern_2:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis was ultimately rejected because the first block would be a\nnovelty in Python's grammar: a block whose only content is a single\nexpression rather than a sequence of statements.\u003c/p\u003e\n\u003ca name=\"user-content-alternatives-for-constant-value-pattern\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAlternatives for constant value pattern\u003c/h3\u003e\u003ca id=\"user-content-alternatives-for-constant-value-pattern\" class=\"anchor\" aria-label=\"Permalink: Alternatives for constant value pattern\" href=\"#alternatives-for-constant-value-pattern\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis is probably the trickiest item. Matching against some pre-defined\nconstants is very common, but the dynamic nature of Python also makes it\nambiguous with capture patterns. Five other alternatives were considered:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse some implicit rules. For example, if a name was defined in the global\nscope, then it refers to a constant, rather than representing a\ncapture pattern:\u003c/p\u003e\n\u003cpre\u003e# Here, the name \"spam\" must be defined in the global scope (and\n# not shadowed locally). \"side\" must be local.\n\nmatch entree[-1]:\n case spam: ... # Compares entree[-1] == spam.\n case side: ... # Assigns side = entree[-1].\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis however can cause surprises and action at a distance if someone\ndefines an unrelated coinciding name before the match statement.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse a rule based on the case of a name. In particular, if the name\nstarts with a lowercase letter it would be a capture pattern, while if\nit starts with uppercase it would refer to a constant:\u003c/p\u003e\n\u003cpre\u003ematch entree[-1]:\n case SPAM: ... # Compares entree[-1] == SPAM.\n case side: ... # Assigns side = entree[-1].\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis works well with the recommendations for naming constants from\n\u003ca href=\"http://www.python.org/dev/peps/pep-0008\" rel=\"nofollow\"\u003ePEP 8\u003c/a\u003e. The main objection is that there's no other part of core\nPython where the case of a name is semantically significant.\nIn addition, Python allows identifiers to use different scripts,\nmany of which (e.g. CJK) don't have a case distinction.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse extra parentheses to indicate lookup semantics for a given name. For\nexample:\u003c/p\u003e\n\u003cpre\u003ematch entree[-1]:\n case (spam): ... # Compares entree[-1] == spam.\n case side: ... # Assigns side = entree[-1].\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis may be a viable option, but it can create some visual noise if used\noften. Also honestly it looks pretty unusual, especially in nested contexts.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis also has the problem that we may want or need parentheses to\ndisambiguate grouping in patterns, e.g. in \u003ccode\u003ePoint(x, y=(y :=\ncomplex()))\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eIntroduce a special symbol, for example \u003ccode\u003e.\u003c/code\u003e, \u003ccode\u003e?\u003c/code\u003e, \u003ccode\u003e$\u003c/code\u003e, or \u003ccode\u003e^\u003c/code\u003e to\nindicate that a given name is a value to be matched against, not\nto be assigned to. An earlier version of this proposal used a\nleading-dot rule:\u003c/p\u003e\n\u003cpre\u003ematch entree[-1]:\n case .spam: ... # Compares entree[-1] == spam.\n case side: ... # Assigns side = entree[-1].\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eWhile potentially useful, it introduces strange-looking new syntax\nwithout making the pattern syntax any more expressive. Indeed,\nnamed constants can be made to work with the existing rules by\nconverting them to \u003ccode\u003eEnum\u003c/code\u003e types, or enclosing them in their own\nnamespace (considered by the authors to be one honking great idea):\u003c/p\u003e\n\u003cpre\u003ematch entree[-1]:\n case Sides.SPAM: ... # Compares entree[-1] == Sides.SPAM.\n case side: ... # Assigns side = entree[-1].\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eIf needed, the leading-dot rule (or a similar variant) could be\nadded back later with no backward-compatibility issues.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eThere was also an idea to make lookup semantics the default, and require\n\u003ccode\u003e$\u003c/code\u003e or \u003ccode\u003e?\u003c/code\u003e to be used in capture patterns:\u003c/p\u003e\n\u003cpre\u003ematch entree[-1]:\n case spam: ... # Compares entree[-1] == spam.\n case side?: ... # Assigns side = entree[-1].\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThere are a few issues with this:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eCapture patterns are more common in typical code, so it is\nundesirable to require special syntax for them.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eThe authors are not aware of any other language that adorns\ncaptures in this way.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eNone of the proposed syntaxes have any precedent in Python;\nno other place in Python that binds names (e.g. \u003ccode\u003eimport\u003c/code\u003e,\n\u003ccode\u003edef\u003c/code\u003e, \u003ccode\u003efor\u003c/code\u003e) uses special marker syntax.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eIt would break the syntactic parallels of the current grammar:\u003c/p\u003e\n\u003cpre\u003ematch coords:\n case ($x, $y):\n return Point(x, y) # Why not \"Point($x, $y)\"?\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eIn the end, these alternatives were rejected because of the mentioned drawbacks.\u003c/p\u003e\n\u003ca name=\"user-content-disallow-float-literals-in-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDisallow float literals in patterns\u003c/h3\u003e\u003ca id=\"user-content-disallow-float-literals-in-patterns\" class=\"anchor\" aria-label=\"Permalink: Disallow float literals in patterns\" href=\"#disallow-float-literals-in-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eBecause of the inexactness of floats, an early version of this proposal\ndid not allow floating-point constants to be used as match patterns. Part\nof the justification for this prohibition is that Rust does this.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHowever, during implementation, it was discovered that distinguishing between\nfloat values and other types required extra code in the VM that would slow\nmatches generally. Given that Python and Rust are very different languages\nwith different user bases and underlying philosophies, it was felt that\nallowing float literals would not cause too much harm, and would be less\nsurprising to users.\u003c/p\u003e\n\u003ca name=\"user-content-range-matching-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRange matching patterns\u003c/h3\u003e\u003ca id=\"user-content-range-matching-patterns\" class=\"anchor\" aria-label=\"Permalink: Range matching patterns\" href=\"#range-matching-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis would allow patterns such as \u003ccode\u003e1...6\u003c/code\u003e. However, there are a host of\nambiguities:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eIs the range open, half-open, or closed? (I.e. is \u003ccode\u003e6\u003c/code\u003e included in the\nabove example or not?)\u003c/li\u003e\n\u003cli\u003eDoes the range match a single number, or a range object?\u003c/li\u003e\n\u003cli\u003eRange matching is often used for character ranges ('a'...'z') but that\nwon't work in Python since there's no character data type, just strings.\u003c/li\u003e\n\u003cli\u003eRange matching can be a significant performance optimization if you can\npre-build a jump table, but that's not generally possible in Python due\nto the fact that names can be dynamically rebound.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eRather than creating a special-case syntax for ranges, it was decided\nthat allowing custom pattern objects (\u003ccode\u003eInRange(0, 6)\u003c/code\u003e) would be more flexible\nand less ambiguous; however those ideas have been postponed for the time\nbeing (See \u003ca href=\"#deferred-ideas\"\u003edeferred ideas\u003c/a\u003e).\u003c/p\u003e\n\u003ca name=\"user-content-use-dispatch-dict-semantics-for-matches\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse dispatch dict semantics for matches\u003c/h3\u003e\u003ca id=\"user-content-use-dispatch-dict-semantics-for-matches\" class=\"anchor\" aria-label=\"Permalink: Use dispatch dict semantics for matches\" href=\"#use-dispatch-dict-semantics-for-matches\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eImplementations for classic \u003ccode\u003eswitch\u003c/code\u003e statement sometimes use a pre-computed\nhash table instead of a chained equality comparisons to gain some performance.\nIn the context of \u003ccode\u003ematch\u003c/code\u003e statement this is technically also possible for\nmatches against literal patterns. However, having subtly different semantics\nfor different kinds of patterns would be too surprising for potentially\nmodest performance win.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe can still experiment with possible performance optimizations in this\ndirection if they will not cause semantic differences.\u003c/p\u003e\n\u003ca name=\"user-content-use-continue-and-break-in-case-clauses\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse \u003ccode\u003econtinue\u003c/code\u003e and \u003ccode\u003ebreak\u003c/code\u003e in case clauses.\u003c/h3\u003e\u003ca id=\"user-content-use-continue-and-break-in-case-clauses\" class=\"anchor\" aria-label=\"Permalink: Use continue and break in case clauses.\" href=\"#use-continue-and-break-in-case-clauses\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eAnother rejected proposal was to define new meanings for \u003ccode\u003econtinue\u003c/code\u003e\nand \u003ccode\u003ebreak\u003c/code\u003e inside of \u003ccode\u003ematch\u003c/code\u003e, which would have the following behavior:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003econtinue\u003c/code\u003e would exit the current case clause and continue matching\nat the next case clause.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003ebreak\u003c/code\u003e would exit the match statement.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eHowever, there is a serious drawback to this proposal: if the \u003ccode\u003ematch\u003c/code\u003e statement\nis nested inside of a loop, the meanings of \u003ccode\u003econtinue\u003c/code\u003e and \u003ccode\u003ebreak\u003c/code\u003e are now\nchanged. This may cause unexpected behavior during refactorings; also, an\nargument can be made that there are other means to get the same behavior (such\nas using guard conditions), and that in practice it's likely that the existing\nbehavior of \u003ccode\u003econtinue\u003c/code\u003e and \u003ccode\u003ebreak\u003c/code\u003e are far more useful.\u003c/p\u003e\n\u003ca name=\"user-content-and-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAND (\u003ccode\u003e\u0026amp;\u003c/code\u003e) patterns\u003c/h3\u003e\u003ca id=\"user-content-and--patterns\" class=\"anchor\" aria-label=\"Permalink: AND (\u0026amp;) patterns\" href=\"#and--patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis proposal defines an OR-pattern (\u003ccode\u003e|\u003c/code\u003e) to match one of several alternates;\nwhy not also an AND-pattern (\u003ccode\u003e\u0026amp;\u003c/code\u003e)? Especially given that some other languages\n(F# for example) support this.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHowever, it's not clear how useful this would be. The semantics for matching\ndictionaries, objects and sequences already incorporates an implicit 'and': all\nattributes and elements mentioned must be present for the match to succeed. Guard\nconditions can also support many of the use cases that a hypothetical 'and'\noperator would be used for.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn the end, it was decided that this would make the syntax more complex without\nadding a significant benefit.\u003c/p\u003e\n\u003ca name=\"user-content-negative-match-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eNegative match patterns\u003c/h3\u003e\u003ca id=\"user-content-negative-match-patterns\" class=\"anchor\" aria-label=\"Permalink: Negative match patterns\" href=\"#negative-match-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA negation of a match pattern using the operator \u003ccode\u003e!\u003c/code\u003e as a prefix would match\nexactly if the pattern itself does not match. For instance, \u003ccode\u003e!(3 | 4)\u003c/code\u003e\nwould match anything except \u003ccode\u003e3\u003c/code\u003e or \u003ccode\u003e4\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis was rejected because there is \u003ca href=\"https://dl.acm.org/doi/abs/10.1145/2480360.2384582\" rel=\"nofollow\"\u003edocumented evidence\u003c/a\u003e that this feature\nis rarely useful (in languages which support it) or used as double negation\n\u003ccode\u003e!!\u003c/code\u003e to control variable scopes and prevent variable bindings (which does\nnot apply to Python). It can also be simulated using guard conditions.\u003c/p\u003e\n\u003ca name=\"user-content-check-exhaustiveness-at-runtime\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCheck exhaustiveness at runtime\u003c/h3\u003e\u003ca id=\"user-content-check-exhaustiveness-at-runtime\" class=\"anchor\" aria-label=\"Permalink: Check exhaustiveness at runtime\" href=\"#check-exhaustiveness-at-runtime\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe question is what to do if no case clause has a matching pattern, and\nthere is no default case. An earlier version of the proposal specified that\nthe behavior in this case would be to throw an exception rather than\nsilently falling through.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe arguments back and forth were many, but in the end the EIBTI (Explicit\nIs Better Than Implicit) argument won out: it's better to have the programmer\nexplicitly throw an exception if that is the behavior they want.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFor cases such as sealed classes and enums, where the patterns are all known\nto be members of a discrete set, \u003ca href=\"#static-checkers-specification\"\u003estatic checkers\u003c/a\u003e can warn about missing\npatterns.\u003c/p\u003e\n\u003ca name=\"user-content-type-annotations-for-pattern-variables\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eType annotations for pattern variables\u003c/h3\u003e\u003ca id=\"user-content-type-annotations-for-pattern-variables\" class=\"anchor\" aria-label=\"Permalink: Type annotations for pattern variables\" href=\"#type-annotations-for-pattern-variables\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe proposal was to combine patterns with type annotations:\u003c/p\u003e\n\u003cpre\u003ematch x:\n case [a: int, b: str]: print(f\"An int {a} and a string {b}:)\n case [a: int, b: int, c: int]: print(f\"Three ints\", a, b, c)\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis idea has a lot of problems. For one, the colon can only\nbe used inside of brackets or parens, otherwise the syntax becomes\nambiguous. And because Python disallows \u003ccode\u003eisinstance()\u003c/code\u003e checks\non generic types, type annotations containing generics will not\nwork as expected.\u003c/p\u003e\n\u003ca name=\"user-content-allow-rest-in-class-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAllow \u003ccode\u003e*rest\u003c/code\u003e in class patterns\u003c/h3\u003e\u003ca id=\"user-content-allow-rest-in-class-patterns\" class=\"anchor\" aria-label=\"Permalink: Allow *rest in class patterns\" href=\"#allow-rest-in-class-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIt was proposed to allow \u003ccode\u003e*rest\u003c/code\u003e in a class pattern, giving a\nvariable to be bound to all positional arguments at once (similar to\nits use in unpacking assignments). It would provide some symmetry\nwith sequence patterns. But it might be confused with a feature to\nprovide the \u003cem\u003evalues\u003c/em\u003e for all positional arguments at once. And there\nseems to be no practical need for it, so it was scrapped. (It could\neasily be added at a later stage if a need arises.)\u003c/p\u003e\n\u003ca name=\"user-content-disallow-a-in-constant-value-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDisallow \u003ccode\u003e_.a\u003c/code\u003e in constant value patterns\u003c/h3\u003e\u003ca id=\"user-content-disallow-_a-in-constant-value-patterns\" class=\"anchor\" aria-label=\"Permalink: Disallow _.a in constant value patterns\" href=\"#disallow-_a-in-constant-value-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe first public draft said that the initial name in a constant value\npattern must not be \u003ccode\u003e_\u003c/code\u003e because \u003ccode\u003e_\u003c/code\u003e has a special meaning in\npattern matching, so this would be invalid:\u003c/p\u003e\n\u003cpre\u003ecase _.a: ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003e(However, \u003ccode\u003ea._\u003c/code\u003e would be legal and load the attribute with name\n\u003ccode\u003e_\u003c/code\u003e of the object \u003ccode\u003ea\u003c/code\u003e as usual.)\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThere was some pushback against this on python-dev (some people have a\nlegitimate use for \u003ccode\u003e_\u003c/code\u003e as an important global variable, esp. in\ni18n) and the only reason for this prohibition was to prevent some\nuser confusion. But it's not the hill to die on.\u003c/p\u003e\n\u003ca name=\"user-content-use-some-other-token-as-wildcard\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse some other token as wildcard\u003c/h3\u003e\u003ca id=\"user-content-use-some-other-token-as-wildcard\" class=\"anchor\" aria-label=\"Permalink: Use some other token as wildcard\" href=\"#use-some-other-token-as-wildcard\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIt has been proposed to use \u003ccode\u003e...\u003c/code\u003e (i.e., the ellipsis token) or\n\u003ccode\u003e*\u003c/code\u003e (star) as a wildcard. However, both these look as if an\narbitrary number of items is omitted:\u003c/p\u003e\n\u003cpre\u003ecase [a, ..., z]: ...\ncase [a, *, z]: ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eBoth look like the would match a sequence of at two or more items,\ncapturing the first and last values.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIn addition, if \u003ccode\u003e*\u003c/code\u003e were to be used as the wildcard character, we\nwould have to come up with some other way to capture the rest of a\nsequence, currently spelled like this:\u003c/p\u003e\n\u003cpre\u003ecase [first, second, *rest]: ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eUsing an ellipsis would also be more confusing in documentation and\nexamples, where \u003ccode\u003e...\u003c/code\u003e is routinely used to indicate something\nobvious or irrelevant. (Yes, this would also be an argument against\nthe other uses of \u003ccode\u003e...\u003c/code\u003e in Python, but that water is already under\nthe bridge.)\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAnother proposal was to use \u003ccode\u003e?\u003c/code\u003e. This could be acceptable, although\nit would require modifying the tokenizer.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAlso, \u003ccode\u003e_\u003c/code\u003e is already used\nas a throwaway target in other contexts, and this use is pretty\nsimilar. This example is from \u003ccode\u003edifflib.py\u003c/code\u003e in the stdlib:\u003c/p\u003e\n\u003cpre\u003efor tag, _, _, j1, j2 in group: ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003ePerhaps the most convincing argument is that \u003ccode\u003e_\u003c/code\u003e is used as the\nwildcard in every other language we've looked at supporting pattern\nmatching: C#, Elixir, Erlang, F#, Haskell, Mathematica, OCaml, Ruby,\nRust, Scala, and Swift. Now, in general, we should not be concerned\ntoo much with what another language does, since Python is clearly\ndifferent from all these languages. However, if there is such an\noverwhelming and strong consensus, Python should not go out of its way\nto do something completely different -- particularly given that \u003ccode\u003e_\u003c/code\u003e\nworks well in Python and is already in use as a throwaway target.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that \u003ccode\u003e_\u003c/code\u003e is not assigned to by patterns -- this avoids\nconflicts with the use of \u003ccode\u003e_\u003c/code\u003e as a marker for translatable strings\nand an alias for \u003ccode\u003egettext.gettext\u003c/code\u003e, as recommended by the\n\u003ccode\u003egettext\u003c/code\u003e module documentation.\u003c/p\u003e\n\u003ca name=\"user-content-use-some-other-syntax-instead-of-for-or-patterns\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eUse some other syntax instead of \u003ccode\u003e|\u003c/code\u003e for OR patterns\u003c/h3\u003e\u003ca id=\"user-content-use-some-other-syntax-instead-of--for-or-patterns\" class=\"anchor\" aria-label=\"Permalink: Use some other syntax instead of | for OR patterns\" href=\"#use-some-other-syntax-instead-of--for-or-patterns\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA few alternatives to using \u003ccode\u003e|\u003c/code\u003e to separate the alternatives in OR\npatterns have been proposed. Instead of:\u003c/p\u003e\n\u003cpre\u003ecase 401|403|404:\n print(\"Some HTTP error\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003ethe following proposals have been fielded:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse a comma:\u003c/p\u003e\n\u003cpre\u003ecase 401, 403, 404:\n print(\"Some HTTP error\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis looks too much like a tuple -- we would have to find a\ndifferent way to spell tuples, and the construct would have to be\nparenthesized inside the argument list of a class pattern. In\ngeneral, commas already have many different meanings in Python, we\nshouldn't add more.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eAllow stacked cases:\u003c/p\u003e\n\u003cpre\u003ecase 401:\ncase 403:\ncase 404:\n print(\"Some HTTP error\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis is how this would be done in C, using its fall-through\nsemantics for cases. However, we don't want to mislead people into\nthinking that \u003ccode\u003ematch\u003c/code\u003e/\u003ccode\u003ecase\u003c/code\u003e uses fall-through semantics (which\nare a common source of bugs in C). Also, this would be a novel\nindentation pattern, which might make it harder to support in IDEs\nand such (it would break the simple rule \"add an indentation level\nafter a line ending in a colon\"). Finally, this wouldn't support\nOR patterns nested inside other patterns.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse \u003ccode\u003ecase in\u003c/code\u003e followed by a comma-separated list:\u003c/p\u003e\n\u003cpre\u003ecase in 401, 403, 404:\n print(\"Some HTTP error\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis wouldn't work for OR patterns nested inside other patterns,\nlike:\u003c/p\u003e\n\u003cpre\u003ecase Point(0|1, 0|1):\n print(\"A corner of the unit square\")\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eUse the \u003ccode\u003eor\u003c/code\u003e keyword:\u003c/p\u003e\n\u003cpre\u003ecase 401 or 403 or 404:\n print(\"Some HTTP error\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis could work, and the readability is not too different from using\n\u003ccode\u003e|\u003c/code\u003e. Some users expressed a preference for \u003ccode\u003eor\u003c/code\u003e because they\nassociate \u003ccode\u003e|\u003c/code\u003e with bitwise OR. However:\u003c/p\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eMany other languages that have pattern matching use \u003ccode\u003e|\u003c/code\u003e (the\nlist includes Elixir, Erlang, F#, Mathematica, OCaml, Ruby, Rust,\nand Scala).\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003e|\u003c/code\u003e is shorter, which may contribute to the readability of\nnested patterns like \u003ccode\u003ePoint(0|1, 0|1)\u003c/code\u003e.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003eSome people mistakenly believe that \u003ccode\u003e|\u003c/code\u003e has the wrong priority;\nbut since patterns don't support other operators it has the same\npriority as in expressions.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003ePython users use \u003ccode\u003eor\u003c/code\u003e very frequently, and may build an\nimpression that it is strongly associated with Boolean\nshort-circuiting.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003e|\u003c/code\u003e is used between alternatives in regular expressions\nand in EBNF grammars (like Python's own).\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003e|\u003c/code\u003e not just used for bitwise OR -- it's used for set unions,\ndict merging (\u003ca href=\"http://www.python.org/dev/peps/pep-0584\" rel=\"nofollow\"\u003ePEP 584\u003c/a\u003e) and is being considered as an\nalternative to \u003ccode\u003etyping.Union\u003c/code\u003e (\u003ca href=\"http://www.python.org/dev/peps/pep-0604\" rel=\"nofollow\"\u003ePEP 604\u003c/a\u003e).\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\u003cp dir=\"auto\"\u003e\u003ccode\u003e|\u003c/code\u003e works better as a visual separator, especially between\nstrings. Compare:\u003c/p\u003e\n\u003cpre\u003ecase \"spam\" or \"eggs\" or \"cheese\":\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eto:\u003c/p\u003e\n\u003cpre\u003ecase \"spam\" | \"eggs\" | \"cheese\":\n\u003c/pre\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-add-an-else-clause\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAdd an \u003ccode\u003eelse\u003c/code\u003e clause\u003c/h3\u003e\u003ca id=\"user-content-add-an-else-clause\" class=\"anchor\" aria-label=\"Permalink: Add an else clause\" href=\"#add-an-else-clause\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWe decided not to add an \u003ccode\u003eelse\u003c/code\u003e clause for several reasons.\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eIt is redundant, since we already have \u003ccode\u003ecase _:\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eThere will forever be confusion about the indentation level of the\n\u003ccode\u003eelse:\u003c/code\u003e -- should it align with the list of cases or with the\n\u003ccode\u003ematch\u003c/code\u003e keyword?\u003c/li\u003e\n\u003cli\u003eCompletionist arguments like \"every other statement has one\" are\nfalse -- only those statements have an \u003ccode\u003eelse\u003c/code\u003e clause where it adds\nnew functionality.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-deferred-ideas\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eDeferred Ideas\u003c/h2\u003e\u003ca id=\"user-content-deferred-ideas\" class=\"anchor\" aria-label=\"Permalink: Deferred Ideas\" href=\"#deferred-ideas\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThere were a number of proposals to extend the matching syntax that we\ndecided to postpone for possible future PEP. These fall into the realm of\n\"cool idea but not essential\", and it was felt that it might be better to\nacquire some real-world data on how the match statement will be used in\npractice before moving forward with some of these proposals.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that in each case, the idea was judged to be a \"two-way door\",\nmeaning that there should be no backwards-compatibility issues with adding\nthese features later.\u003c/p\u003e\n\u003ca name=\"user-content-one-off-syntax-variant\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eOne-off syntax variant\u003c/h3\u003e\u003ca id=\"user-content-one-off-syntax-variant\" class=\"anchor\" aria-label=\"Permalink: One-off syntax variant\" href=\"#one-off-syntax-variant\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWhile inspecting some code-bases that may benefit the most from the proposed\nsyntax, it was found that single clause matches would be used relatively often,\nmostly for various special-casing. In other languages this is supported in\nthe form of one-off matches. We proposed to support such one-off matches too:\u003c/p\u003e\n\u003cpre\u003eif match value as pattern [and guard]:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eor, alternatively, without the \u003ccode\u003eif\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003ematch value as pattern [if guard]:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eas equivalent to the following expansion:\u003c/p\u003e\n\u003cpre\u003ematch value:\n case pattern [if guard]:\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eTo illustrate how this will benefit readability, consider this (slightly\nsimplified) snippet from real code:\u003c/p\u003e\n\u003cpre\u003eif isinstance(node, CallExpr):\n if (isinstance(node.callee, NameExpr) and len(node.args) == 1 and\n isinstance(node.args[0], NameExpr)):\n call = node.callee.name\n arg = node.args[0].name\n ... # Continue special-casing 'call' and 'arg'\n... # Follow with common code\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis can be rewritten in a more straightforward way as:\u003c/p\u003e\n\u003cpre\u003eif match node as CallExpr(callee=NameExpr(name=call), args=[NameExpr(name=arg)]):\n ... # Continue special-casing 'call' and 'arg'\n... # Follow with common code\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis one-off form would not allow \u003ccode\u003eelif match\u003c/code\u003e statements, as it was only\nmeant to handle a single pattern case. It was intended to be special case\nof a \u003ccode\u003ematch\u003c/code\u003e statement, not a special case of an \u003ccode\u003eif\u003c/code\u003e statement:\u003c/p\u003e\n\u003cpre\u003eif match value_1 as patter_1 [and guard_1]:\n ...\nelif match value_2 as pattern_2 [and guard_2]: # Not allowed\n ...\nelif match value_3 as pattern_3 [and guard_3]: # Not allowed\n ...\nelse: # Also not allowed\n ...\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThis would defeat the purpose of one-off matches as a complement to exhaustive\nfull matches - it's better and clearer to use a full match in this case.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eSimilarly, \u003ccode\u003eif not match\u003c/code\u003e would not be allowed, since \u003ccode\u003ematch ... as ...\u003c/code\u003e is not\nan expression. Nor do we propose a \u003ccode\u003ewhile match\u003c/code\u003e construct present in some languages\nwith pattern matching, since although it may be handy, it will likely be used\nrarely.\u003c/p\u003e\n\u003ca name=\"user-content-other-pattern-based-constructions\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eOther pattern-based constructions\u003c/h3\u003e\u003ca id=\"user-content-other-pattern-based-constructions\" class=\"anchor\" aria-label=\"Permalink: Other pattern-based constructions\" href=\"#other-pattern-based-constructions\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eMany other languages supporting pattern-matching use it as a basis for multiple\nlanguage constructs, including a matching operator, a generalized form\nof assignment, a filter for loops, a method for synchronizing communication,\nor specialized if statements. Some of these were mentioned in the discussion\nof the first draft. Another question asked was why this particular form (joining\nbinding and conditional selection) was chosen while other forms were not.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIntroducing more uses of patterns would be too bold and premature given the\nexperience we have using patterns, and would make this proposal too\ncomplicated. The statement as presented provides a form of the feature that\nis sufficiently general to be useful while being self-contained, and without\nhaving a massive impact on the syntax and semantics of the language as a whole.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAfter some experience with this feature, the community may have a better\nfeeling for what other uses of pattern matching could be valuable in Python.\u003c/p\u003e\n\u003ca name=\"user-content-algebraic-matching-of-repeated-names\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAlgebraic matching of repeated names\u003c/h3\u003e\u003ca id=\"user-content-algebraic-matching-of-repeated-names\" class=\"anchor\" aria-label=\"Permalink: Algebraic matching of repeated names\" href=\"#algebraic-matching-of-repeated-names\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eA technique occasionally seen in functional languages like Erlang and Elixir is\nto use a match variable multiple times in the same pattern:\u003c/p\u003e\n\u003cpre\u003ematch value:\n case Point(x, x):\n print(\"Point is on a diagonal!\")\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eThe idea here is that the first appearance of \u003ccode\u003ex\u003c/code\u003e would bind the value\nto the name, and subsequent occurrences would verify that the incoming\nvalue was equal to the value previously bound. If the value was not equal,\nthe match would fail.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eHowever, there are a number of subtleties involved with mixing load-store\nsemantics for capture patterns. For the moment, we decided to make repeated\nuse of names within the same pattern an error; we can always relax this\nrestriction later without affecting backwards compatibility.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNote that you \u003cstrong\u003ecan\u003c/strong\u003e use the same name more than once in alternate choices:\u003c/p\u003e\n\u003cpre\u003ematch value:\n case x | [x]:\n # etc.\n\u003c/pre\u003e\n\u003ca name=\"user-content-custom-matching-protocol\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCustom matching protocol\u003c/h3\u003e\u003ca id=\"user-content-custom-matching-protocol\" class=\"anchor\" aria-label=\"Permalink: Custom matching protocol\" href=\"#custom-matching-protocol\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eDuring the initial design discussions for this PEP, there were a lot of ideas\nthrown around about custom matchers. There were a couple of motivations for\nthis:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eSome classes might want to expose a different set of \"matchable\" names\nthan the actual class properties.\u003c/li\u003e\n\u003cli\u003eSome classes might have properties that are expensive to calculate, and\ntherefore shouldn't be evaluated unless the match pattern actually needed\naccess to them.\u003c/li\u003e\n\u003cli\u003eThere were ideas for exotic matchers such as \u003ccode\u003eIsInstance()\u003c/code\u003e,\n\u003ccode\u003eInRange()\u003c/code\u003e, \u003ccode\u003eRegexMatchingGroup()\u003c/code\u003e and so on.\u003c/li\u003e\n\u003cli\u003eIn order for built-in types and standard library classes to be able\nto support matching in a reasonable and intuitive way, it was believed\nthat these types would need to implement special matching logic.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eThese customized match behaviors would be controlled by a special\n\u003ccode\u003e__match__\u003c/code\u003e method on the class name. There were two competing variants:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eA 'full-featured' match protocol which would pass in not only\nthe subject to be matched, but detailed information about\nwhich attributes the specified pattern was interested in.\u003c/li\u003e\n\u003cli\u003eA simplified match protocol, which only passed in the subject value,\nand which returned a \"proxy object\" (which in most cases could be\njust the subject) containing the matchable attributes.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eHere's an example of one version of the more complex protocol proposed:\u003c/p\u003e\n\u003cpre\u003ematch expr:\n case BinaryOp(left=Number(value=x), op=op, right=Number(value=y)):\n ...\n\nfrom types import PatternObject\nBinaryOp.__match__(\n (),\n {\n \"left\": PatternObject(Number, (), {\"value\": ...}, -1, False),\n \"op\": ...,\n \"right\": PatternObject(Number, (), {\"value\": ...}, -1, False),\n },\n -1,\n False,\n)\n\u003c/pre\u003e\n\u003cp dir=\"auto\"\u003eOne drawback of this protocol is that the arguments to \u003ccode\u003e__match__\u003c/code\u003e\nwould be expensive to construct, and could not be pre-computed due to\nthe fact that, because of the way names are bound, there are no real\nconstants in Python. It also meant that the \u003ccode\u003e__match__\u003c/code\u003e method would\nhave to re-implement much of the logic of matching which would otherwise\nbe implemented in C code in the Python VM. As a result, this option would\nperform poorly compared to an equivalent \u003ccode\u003eif\u003c/code\u003e-statement.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe simpler protocol suffered from the fact that although it was more\nperformant, it was much less flexible, and did not allow for many of\nthe creative custom matchers that people were dreaming up.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eLate in the design process, however, it was realized that the need for\na custom matching protocol was much less than anticipated. Virtually\nall the realistic (as opposed to fanciful) uses cases brought up could\nbe handled by the built-in matching behavior, although in a few cases\nan extra guard condition was required to get the desired effect.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eMoreover, it turned out that none of the standard library classes really\nneeded any special matching support other than an appropriate\n\u003ccode\u003e__match_args__\u003c/code\u003e property.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe decision to postpone this feature came with a realization that this is\nnot a one-way door; that a more flexible and customizable matching protocol\ncan be added later, especially as we gain more experience with real-world\nuse cases and actual user needs.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe authors of this PEP expect that the \u003ccode\u003ematch\u003c/code\u003e statement will evolve\nover time as usage patterns and idioms evolve, in a way similar to what\nother \"multi-stage\" PEPs have done in the past. When this happens, the\nextended matching issue can be revisited.\u003c/p\u003e\n\u003ca name=\"user-content-parameterized-matching-syntax\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eParameterized Matching Syntax\u003c/h3\u003e\u003ca id=\"user-content-parameterized-matching-syntax\" class=\"anchor\" aria-label=\"Permalink: Parameterized Matching Syntax\" href=\"#parameterized-matching-syntax\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e(Also known as \"Class Instance Matchers\".)\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis is another variant of the \"custom match classes\" idea that would allow\ndiverse kinds of custom matchers mentioned in the previous section -- however,\ninstead of using an extended matching protocol, it would be achieved by\nintroducing an additional pattern type with its own syntax. This pattern type\nwould accept two distinct sets of parameters: one set which consists of the\nactual parameters passed into the pattern object's constructor, and another\nset representing the binding variables for the pattern.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode\u003e__match__\u003c/code\u003e method of these objects could use the constructor parameter\nvalues in deciding what was a valid match.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThis would allow patterns such as \u003ccode\u003eInRange\u0026lt;0, 6\u0026gt;(value)\u003c/code\u003e, which would match\na number in the range 0..6 and assign the matched value to 'value'. Similarly,\none could have a pattern which tests for the existence of a named group in\na regular expression match result (different meaning of the word 'match').\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAlthough there is some support for this idea, there was a lot of bikeshedding\non the syntax (there are not a lot of attractive options available)\nand no clear consensus was reached, so it was decided that for now, this\nfeature is not essential to the PEP.\u003c/p\u003e\n\u003ca name=\"user-content-pattern-utility-library\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePattern Utility Library\u003c/h3\u003e\u003ca id=\"user-content-pattern-utility-library\" class=\"anchor\" aria-label=\"Permalink: Pattern Utility Library\" href=\"#pattern-utility-library\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eBoth of the previous ideas would be accompanied by a new Python standard\nlibrary module which would contain a rich set of useful matchers.\nHowever, it is not really possible to implement such a library without\nadopting one of the extended pattern proposals given in the previous sections,\nso this idea is also deferred.\u003c/p\u003e\n\u003ca name=\"user-content-acknowledgments\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAcknowledgments\u003c/h2\u003e\u003ca id=\"user-content-acknowledgments\" class=\"anchor\" aria-label=\"Permalink: Acknowledgments\" href=\"#acknowledgments\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWe are grateful for the help of the following individuals (among many\nothers) for helping out during various phases of the writing of this\nPEP:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eGregory P. Smith\u003c/li\u003e\n\u003cli\u003eJim Jewett\u003c/li\u003e\n\u003cli\u003eMark Shannon\u003c/li\u003e\n\u003cli\u003eNate Lust\u003c/li\u003e\n\u003cli\u003eTaine Zhao\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-version-history\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eVersion History\u003c/h2\u003e\u003ca id=\"user-content-version-history\" class=\"anchor\" aria-label=\"Permalink: Version History\" href=\"#version-history\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003col dir=\"auto\"\u003e\n\u003cli\u003eInitial version\u003c/li\u003e\n\u003cli\u003eSubstantial rewrite, including:\u003cul dir=\"auto\"\u003e\n\u003cli\u003eMinor clarifications, grammar and typo corrections\u003c/li\u003e\n\u003cli\u003eRename various concepts\u003c/li\u003e\n\u003cli\u003eAdditional discussion of rejected ideas, including:\u003cul dir=\"auto\"\u003e\n\u003cli\u003eWhy we choose \u003ccode\u003e_\u003c/code\u003e for wildcard patterns\u003c/li\u003e\n\u003cli\u003eWhy we choose \u003ccode\u003e|\u003c/code\u003e for OR patterns\u003c/li\u003e\n\u003cli\u003eWhy we choose not to use special syntax for capture variables\u003c/li\u003e\n\u003cli\u003eWhy this pattern matching operation and not others\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eClarify exception and side effect semantics\u003c/li\u003e\n\u003cli\u003eClarify partial binding semantics\u003c/li\u003e\n\u003cli\u003eDrop restriction on use of \u003ccode\u003e_\u003c/code\u003e in load contexts\u003c/li\u003e\n\u003cli\u003eDrop the default single positional argument being the whole\nsubject except for a handful of built-in types\u003c/li\u003e\n\u003cli\u003eSimplify behavior of \u003ccode\u003e__match_args__\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eDrop the \u003ccode\u003e__match__\u003c/code\u003e protocol (moved to \u003ca href=\"#deferred-ideas\"\u003edeferred ideas\u003c/a\u003e)\u003c/li\u003e\n\u003cli\u003eDrop \u003ccode\u003eImpossibleMatchError\u003c/code\u003e exception\u003c/li\u003e\n\u003cli\u003eDrop leading dot for loads (moved to \u003ca href=\"#deferred-ideas\"\u003edeferred ideas\u003c/a\u003e)\u003c/li\u003e\n\u003cli\u003eReworked the initial sections (everything before \u003ca href=\"#syntax-and-semantics\"\u003esyntax\u003c/a\u003e)\u003c/li\u003e\n\u003cli\u003eAdded an overview of all the types of patterns before the\ndetailed description\u003c/li\u003e\n\u003cli\u003eAdded simplified syntax next to the description of each pattern\u003c/li\u003e\n\u003cli\u003eSeparate description of the wildcard from capture patterns\u003c/li\u003e\n\u003cli\u003eAdded Daniel F Moisset as sixth co-author\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003ca name=\"user-content-references\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eReferences\u003c/h2\u003e\u003ca id=\"user-content-references\" class=\"anchor\" aria-label=\"Permalink: References\" href=\"#references\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cmarkdown-accessiblity-table\u003e\u003ctable frame=\"void\" id=\"user-content-id5\" rules=\"none\"\u003e\n\n\u003ctbody valign=\"top\"\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ca href=\"#id4\"\u003e[1]\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/gvanrossum/patma/blob/master/EXAMPLES.md\"\u003ehttps://github.com/gvanrossum/patma/blob/master/EXAMPLES.md\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\u003c/markdown-accessiblity-table\u003e\n\u003ca name=\"user-content-appendix-a-full-grammar\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eAppendix A -- Full Grammar\u003c/h2\u003e\u003ca id=\"user-content-appendix-a----full-grammar\" class=\"anchor\" aria-label=\"Permalink: Appendix A -- Full Grammar\" href=\"#appendix-a----full-grammar\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eHere is the full grammar for \u003ccode\u003ematch_stmt\u003c/code\u003e. This is an additional\nalternative for \u003ccode\u003ecompound_stmt\u003c/code\u003e. It should be understood that\n\u003ccode\u003ematch\u003c/code\u003e and \u003ccode\u003ecase\u003c/code\u003e are soft keywords, i.e. they are not reserved\nwords in other grammatical contexts (including at the start of a line\nif there is no colon where expected). By convention, hard keywords\nuse single quotes while soft keywords use double quotes.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eOther notation used beyond standard EBNF:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ccode\u003eSEP.RULE+\u003c/code\u003e is shorthand for \u003ccode\u003eRULE (SEP RULE)*\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e!RULE\u003c/code\u003e is a negative lookahead assertion\u003c/li\u003e\n\u003c/ul\u003e\n\u003cpre lang=\"text\"\u003ematch_expr:\n | star_named_expression ',' star_named_expressions?\n | named_expression\nmatch_stmt: \"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT\ncase_block: \"case\" patterns [guard] ':' block\nguard: 'if' named_expression\npatterns: value_pattern ',' [values_pattern] | pattern\npattern: walrus_pattern | or_pattern\nwalrus_pattern: NAME ':=' or_pattern\nor_pattern: '|'.closed_pattern+\nclosed_pattern:\n | capture_pattern\n | literal_pattern\n | constant_pattern\n | group_pattern\n | sequence_pattern\n | mapping_pattern\n | class_pattern\ncapture_pattern: NAME !('.' | '(' | '=')\nliteral_pattern:\n | signed_number !('+' | '-')\n | signed_number '+' NUMBER\n | signed_number '-' NUMBER\n | strings\n | 'None'\n | 'True'\n | 'False'\nconstant_pattern: attr !('.' | '(' | '=')\ngroup_pattern: '(' patterns ')'\nsequence_pattern: '[' [values_pattern] ']' | '(' ')'\nmapping_pattern: '{' items_pattern? '}'\nclass_pattern:\n | name_or_attr '(' ')'\n | name_or_attr '(' ','.pattern+ ','? ')'\n | name_or_attr '(' ','.keyword_pattern+ ','? ')'\n | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'\nsigned_number: NUMBER | '-' NUMBER\nattr: name_or_attr '.' NAME\nname_or_attr: attr | NAME\nvalues_pattern: ','.value_pattern+ ','?\nitems_pattern: ','.key_value_pattern+ ','?\nkeyword_pattern: NAME '=' or_pattern\nvalue_pattern: '*' capture_pattern | pattern\nkey_value_pattern:\n | (literal_pattern | constant_pattern) ':' or_pattern\n | '**' capture_pattern\n\u003c/pre\u003e\n\u003ca name=\"user-content-copyright\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eCopyright\u003c/h2\u003e\u003ca id=\"user-content-copyright\" class=\"anchor\" aria-label=\"Permalink: Copyright\" href=\"#copyright\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis document is placed in the public domain or under the\nCC0-1.0-Universal license, whichever is more permissive.\u003c/p\u003e\n\n\u003c/article\u003e","renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":"/python/.github/blob/5a0a7cb55767fb3667fe2391bcb66bda638edcb4/FUNDING.yml","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":true,"symbols":[]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/python/peps/branches":{"post":"GDsAIimqekoGGZSXy6bKbklHyBGUyrkn2O971DSzzzDpT7-h_10icjQ9gNSidTpl8UP0mwK9YGFP_-wIo3-9mQ"},"/repos/preferences":{"post":"uuaQPm8IbWnmy9x4a41oZoa9_HVmQiRvFAcQO8r5AK3xuNJzbEwpnYSAKfqzv2hurorySuYjmN-UWRbD4AMhmg"}}},"title":"peps/peps/pep-0622.rst at main · python/peps","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-96e76d5fdb2c.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"overview_shared_code_dropdown_button":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}</script> <div data-target="react-app.reactRoot"><style data-styled="true" data-styled-version="5.3.11">.gISSDQ{width:100%;}/*!sc*/ @media screen and (min-width:544px){.gISSDQ{width:100%;}}/*!sc*/ @media screen and (min-width:768px){.gISSDQ{width:auto;}}/*!sc*/ .bHLmSv{position:absolute;inset:0 -2px;cursor:col-resize;background-color:transparent;-webkit-transition-delay:0.1s;transition-delay:0.1s;}/*!sc*/ .bHLmSv:hover{background-color:var(--bgColor-neutral-muted,var(--color-neutral-muted,rgba(175,184,193,0.2)));}/*!sc*/ .leYMvG{margin-left:auto;margin-right:auto;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;padding-bottom:40px;max-width:100%;margin-top:0;}/*!sc*/ .KMPzq{display:inherit;}/*!sc*/ .hfKjHv{width:100%;}/*!sc*/ .gZWyZE{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:8px;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;}/*!sc*/ .dwYKDk{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:start;-webkit-box-align:start;-ms-flex-align:start;align-items:start;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;gap:8px;}/*!sc*/ .ibcGmb{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:start;-webkit-box-align:start;-ms-flex-align:start;align-items:start;min-width:0;}/*!sc*/ .hKaEJF{display:block;margin-right:8px;}/*!sc*/ @media screen and (min-width:1360px){.hKaEJF{display:block;}}/*!sc*/ .XosP{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;font-size:14px;}/*!sc*/ .bCKfWo[data-size="medium"]{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));padding-left:8px;padding-right:8px;display:none;}/*!sc*/ @media screen and (max-width:768px){.bCKfWo[data-size="medium"]{display:block;}}/*!sc*/ .gUkoLg{-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}/*!sc*/ .dmxRgG[data-size="medium"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ .dmxRgG[data-size="medium"] svg{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .dmxRgG[data-size="medium"] > span{width:inherit;}/*!sc*/ .bZBlpz{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;}/*!sc*/ .lhTYNA{margin-right:4px;color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .dbrgmi{font-size:14px;min-width:0;max-width:125px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}/*!sc*/ .bmcJak{min-width:0;}/*!sc*/ .dHJiml{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-left:8px;padding-right:8px;min-width:0;}/*!sc*/ .cEytCf{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;font-size:16px;min-width:0;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;max-width:100%;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}/*!sc*/ .fzFXnm{max-width:100%;}/*!sc*/ .iMnkmv{max-width:100%;list-style:none;display:inline-block;}/*!sc*/ .ghzDag{display:inline-block;max-width:100%;}/*!sc*/ .kHuKdh{font-weight:600;}/*!sc*/ .hzJBof{padding-left:4px;padding-right:4px;font-weight:400;color:var(--fgColor-muted,var(--color-fg-muted,#656d76));font-size:16px;}/*!sc*/ .kgiVEz{font-weight:400;}/*!sc*/ .jGhzSQ{font-weight:600;display:inline-block;max-width:100%;font-size:16px;}/*!sc*/ .faNtbn{min-height:32px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:start;-webkit-box-align:start;-ms-flex-align:start;align-items:start;}/*!sc*/ .fmQaBv{margin-left:4px;margin-right:4px;}/*!sc*/ .vcvyP{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;min-width:160px;}/*!sc*/ .dwNhzn[data-size="medium"][data-no-visuals]{border-top-left-radius:0;border-bottom-left-radius:0;display:none;}/*!sc*/ .fGwBZA[data-size="medium"][data-no-visuals]{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .dJxjrT{margin-left:16px;margin-right:16px;}/*!sc*/ .eFxKDQ{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}/*!sc*/ .dzCJzi{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:8px;min-width:273px;padding:8px;}/*!sc*/ @media screen and (min-width:544px){.dzCJzi{-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;}}/*!sc*/ .ldRxiI{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}/*!sc*/ .fVkfyA{width:100%;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;min-width:0;margin-right:0;}/*!sc*/ .gNAmSV{height:40px;padding-left:4px;padding-bottom:16px;}/*!sc*/ .jNEwzY{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}/*!sc*/ .bsDwxw{font-size:12px;-webkit-flex:auto;-ms-flex:auto;flex:auto;padding-right:16px;color:var(--fgColor-muted,var(--color-fg-muted,#656d76));min-width:0;}/*!sc*/ .jdLMhu{top:0px;z-index:4;background:var(--bgColor-default,var(--color-canvas-default));position:-webkit-sticky;position:sticky;}/*!sc*/ .tOISc{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;position:absolute;}/*!sc*/ .hqwSEx{display:none;min-width:0;padding-top:8px;padding-bottom:8px;}/*!sc*/ .bDVoEr{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;overflow:hidden;margin-left:8px;margin-right:8px;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;width:100%;}/*!sc*/ .kYLlPM{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}/*!sc*/ .gYjEmn{margin-left:4px;margin-right:8px;}/*!sc*/ .kGqOLL{text-overflow:ellipsis;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}/*!sc*/ .fHind{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;font-size:14px;min-width:0;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;max-width:100%;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}/*!sc*/ .oDtgN{padding-left:4px;padding-right:4px;font-weight:400;color:var(--fgColor-muted,var(--color-fg-muted,#656d76));font-size:14px;}/*!sc*/ .dnZoUW{font-weight:600;display:inline-block;max-width:100%;font-size:14px;}/*!sc*/ .jRZWlf[data-size="small"]{color:var(--fgColor-default,var(--color-fg-default,#1F2328));margin-left:8px;}/*!sc*/ .kTvpNk{padding-left:8px;padding-top:8px;padding-bottom:8px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex:1;-ms-flex:1;flex:1;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;background-color:var(--bgColor-muted,var(--color-canvas-subtle,#f6f8fa));border:1px solid var(--borderColor-default,var(--color-border-default));border-radius:6px 6px 0px 0px;}/*!sc*/ .iNMjfP{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:8px;min-width:0;}/*!sc*/ .gtTaSn{font-size:14px;}/*!sc*/ .dXYHoy{--separator-color:transparent;}/*!sc*/ .jBWIdY{--separator-color:var(--borderColor-default,var(--color-border-default,#d0d7de));}/*!sc*/ .kcLCKF{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:8px;margin-right:8px;}/*!sc*/ .kVWtTz{gap:8px;}/*!sc*/ .gWqxTd{padding-left:8px;padding-right:8px;}/*!sc*/ .gWqxTd linkButtonSx:hover:not([disabled]){-webkit-text-decoration:none;text-decoration:none;}/*!sc*/ .gWqxTd linkButtonSx:focus:not([disabled]){-webkit-text-decoration:none;text-decoration:none;}/*!sc*/ .gWqxTd linkButtonSx:active:not([disabled]){-webkit-text-decoration:none;text-decoration:none;}/*!sc*/ .ivobqY[data-size="small"][data-no-visuals]{border-top-left-radius:0;border-bottom-left-radius:0;}/*!sc*/ .iNRSob[data-size="small"][data-no-visuals]{color:var(--fgColor-muted,var(--color-fg-muted));margin-right:8px;}/*!sc*/ .ffkqe[data-size="small"][data-no-visuals]{color:var(--fgColor-muted,var(--color-fg-muted,#656d76));}/*!sc*/ .hGyMdv{border:1px solid;border-top:none;border-color:var(--borderColor-default,var(--color-border-default,#d0d7de));border-radius:0px 0px 6px 6px;min-width:273px;}/*!sc*/ .fGqKFv{background-color:var(--bgColor-default,var(--color-canvas-default));border:0px;border-width:0;border-radius:0px 0px 6px 6px;padding:0;min-width:0;margin-top:46px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}/*!sc*/ .eoaCFS{border-bottom-left-radius:6px;border-bottom-right-radius:6px;padding:32px;min-width:0;}/*!sc*/ .cCoXib{position:fixed;top:0;right:0;height:100%;width:15px;-webkit-transition:-webkit-transform 0.3s;-webkit-transition:transform 0.3s;transition:transform 0.3s;z-index:1;}/*!sc*/ .cCoXib:hover{-webkit-transform:scaleX(1.5);-ms-transform:scaleX(1.5);transform:scaleX(1.5);}/*!sc*/ data-styled.g1[id="Box-sc-g0xbh4-0"]{content:"gISSDQ,bHLmSv,leYMvG,KMPzq,hfKjHv,gZWyZE,dwYKDk,ibcGmb,hKaEJF,XosP,bCKfWo,gUkoLg,dmxRgG,bZBlpz,lhTYNA,dbrgmi,bmcJak,dHJiml,cEytCf,fzFXnm,iMnkmv,ghzDag,kHuKdh,hzJBof,kgiVEz,jGhzSQ,faNtbn,fmQaBv,vcvyP,dwNhzn,fGwBZA,dJxjrT,eFxKDQ,dzCJzi,ldRxiI,fVkfyA,gNAmSV,jNEwzY,bsDwxw,jdLMhu,tOISc,hqwSEx,bDVoEr,kYLlPM,gYjEmn,kGqOLL,fHind,oDtgN,dnZoUW,jRZWlf,kTvpNk,iNMjfP,gtTaSn,dXYHoy,jBWIdY,kcLCKF,kVWtTz,gWqxTd,ivobqY,iNRSob,ffkqe,hGyMdv,fGqKFv,eoaCFS,cCoXib,"}/*!sc*/ .hWlpPn{position:relative;display:inline-block;}/*!sc*/ .hWlpPn::after{position:absolute;z-index:1000000;display:none;padding:0.5em 0.75em;font:normal normal 11px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";-webkit-font-smoothing:subpixel-antialiased;color:var(--tooltip-fgColor,var(--fgColor-onEmphasis,var(--color-fg-on-emphasis,#ffffff)));text-align:center;-webkit-text-decoration:none;text-decoration:none;text-shadow:none;text-transform:none;-webkit-letter-spacing:normal;-moz-letter-spacing:normal;-ms-letter-spacing:normal;letter-spacing:normal;word-wrap:break-word;white-space:pre;pointer-events:none;content:attr(aria-label);background:var(--tooltip-bgColor,var(--bgColor-emphasis,var(--color-neutral-emphasis-plus,#24292f)));border-radius:6px;opacity:0;}/*!sc*/ @-webkit-keyframes tooltip-appear{from{opacity:0;}to{opacity:1;}}/*!sc*/ @keyframes tooltip-appear{from{opacity:0;}to{opacity:1;}}/*!sc*/ .hWlpPn:hover::after,.hWlpPn:active::after,.hWlpPn:focus::after,.hWlpPn:focus-within::after{display:inline-block;-webkit-text-decoration:none;text-decoration:none;-webkit-animation-name:tooltip-appear;animation-name:tooltip-appear;-webkit-animation-duration:0.1s;animation-duration:0.1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:ease-in;animation-timing-function:ease-in;-webkit-animation-delay:0s;animation-delay:0s;}/*!sc*/ .hWlpPn.tooltipped-no-delay:hover::after,.hWlpPn.tooltipped-no-delay:active::after,.hWlpPn.tooltipped-no-delay:focus::after,.hWlpPn.tooltipped-no-delay:focus-within::after{-webkit-animation-delay:0s;animation-delay:0s;}/*!sc*/ .hWlpPn.tooltipped-multiline:hover::after,.hWlpPn.tooltipped-multiline:active::after,.hWlpPn.tooltipped-multiline:focus::after,.hWlpPn.tooltipped-multiline:focus-within::after{display:table-cell;}/*!sc*/ .hWlpPn.tooltipped-s::after,.hWlpPn.tooltipped-se::after,.hWlpPn.tooltipped-sw::after{top:100%;right:50%;margin-top:6px;}/*!sc*/ .hWlpPn.tooltipped-se::after{right:auto;left:50%;margin-left:-16px;}/*!sc*/ .hWlpPn.tooltipped-sw::after{margin-right:-16px;}/*!sc*/ .hWlpPn.tooltipped-n::after,.hWlpPn.tooltipped-ne::after,.hWlpPn.tooltipped-nw::after{right:50%;bottom:100%;margin-bottom:6px;}/*!sc*/ .hWlpPn.tooltipped-ne::after{right:auto;left:50%;margin-left:-16px;}/*!sc*/ .hWlpPn.tooltipped-nw::after{margin-right:-16px;}/*!sc*/ .hWlpPn.tooltipped-s::after,.hWlpPn.tooltipped-n::after{-webkit-transform:translateX(50%);-ms-transform:translateX(50%);transform:translateX(50%);}/*!sc*/ .hWlpPn.tooltipped-w::after{right:100%;bottom:50%;margin-right:6px;-webkit-transform:translateY(50%);-ms-transform:translateY(50%);transform:translateY(50%);}/*!sc*/ .hWlpPn.tooltipped-e::after{bottom:50%;left:100%;margin-left:6px;-webkit-transform:translateY(50%);-ms-transform:translateY(50%);transform:translateY(50%);}/*!sc*/ .hWlpPn.tooltipped-multiline::after{width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:250px;word-wrap:break-word;white-space:pre-line;border-collapse:separate;}/*!sc*/ .hWlpPn.tooltipped-multiline.tooltipped-s::after,.hWlpPn.tooltipped-multiline.tooltipped-n::after{right:auto;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);}/*!sc*/ .hWlpPn.tooltipped-multiline.tooltipped-w::after,.hWlpPn.tooltipped-multiline.tooltipped-e::after{right:100%;}/*!sc*/ .hWlpPn.tooltipped-align-right-2::after{right:0;margin-right:0;}/*!sc*/ .hWlpPn.tooltipped-align-left-2::after{left:0;margin-left:0;}/*!sc*/ data-styled.g16[id="Tooltip__TooltipBase-sc-17tf59c-0"]{content:"hWlpPn,"}/*!sc*/ .eAtkQz{display:inline-block;overflow:hidden;text-overflow:ellipsis;vertical-align:top;white-space:nowrap;max-width:125px;max-width:100%;}/*!sc*/ data-styled.g18[id="Truncate__StyledTruncate-sc-23o1d2-0"]{content:"eAtkQz,"}/*!sc*/ </style><meta data-hydrostats="publish"/> <!-- --> <!-- --> <button hidden="" data-testid="header-permalink-button" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden=""></button><div><div style="--sticky-pane-height:100vh;--spacing:var(--spacing-none)" class="Box-sc-g0xbh4-0 prc-PageLayout-PageLayoutRoot-1zlEO"><div class="Box-sc-g0xbh4-0 prc-PageLayout-PageLayoutWrapper-s2ao4" data-width="full"><div class="Box-sc-g0xbh4-0 prc-PageLayout-PageLayoutContent-jzDMn"><div tabindex="0" class="Box-sc-g0xbh4-0 gISSDQ"><div class="Box-sc-g0xbh4-0 prc-PageLayout-PaneWrapper-nGO0U ReposFileTreePane-module__Pane--wS7IV ReposFileTreePane-module__HideTree--zU_Nd ReposFileTreePane-module__HidePane--Gj4XZ" style="--offset-header:0px;--spacing-row:var(--spacing-none);--spacing-column:var(--spacing-none)" data-is-hidden="false" data-position="start" data-sticky="true"><div class="Box-sc-g0xbh4-0 prc-PageLayout-HorizontalDivider-CYLp5 prc-PageLayout-PaneHorizontalDivider-4exOb" data-variant="none" data-position="start" style="--spacing-divider:var(--spacing-none);--spacing:var(--spacing-none)"></div><div class="Box-sc-g0xbh4-0 prc-PageLayout-Pane-Vl5LI" data-resizable="true" style="--spacing:var(--spacing-none);--pane-min-width:256px;--pane-max-width:calc(100vw - var(--pane-max-width-diff));--pane-width-size:var(--pane-width-large);--pane-width:320px"></div><div class="Box-sc-g0xbh4-0 prc-PageLayout-VerticalDivider-4A4Qm prc-PageLayout-PaneVerticalDivider-1c9vy" data-variant="none" data-position="start" style="--spacing:var(--spacing-none)"><div role="slider" aria-label="Draggable pane splitter" aria-valuemin="0" aria-valuemax="0" aria-valuenow="0" aria-valuetext="Pane width 0 pixels" tabindex="0" class="Box-sc-g0xbh4-0 bHLmSv"></div></div></div></div><div class="Box-sc-g0xbh4-0 prc-PageLayout-ContentWrapper-b-QRo CodeView-module__SplitPageLayout_Content--qxR1C" data-is-hidden="false"><div class="Box-sc-g0xbh4-0"></div><div class="Box-sc-g0xbh4-0 prc-PageLayout-Content--F7-I" data-width="full" style="--spacing:var(--spacing-none)"><div data-selector="repos-split-pane-content" tabindex="0" class="Box-sc-g0xbh4-0 leYMvG"><div class="Box-sc-g0xbh4-0 KMPzq"><div class="Box-sc-g0xbh4-0 hfKjHv container"><div class="px-3 pt-3 pb-0" id="StickyHeader"><div class="Box-sc-g0xbh4-0 gZWyZE"><div class="Box-sc-g0xbh4-0 dwYKDk"><div class="Box-sc-g0xbh4-0 ibcGmb react-code-view-header-wrap--narrow"><div class="Box-sc-g0xbh4-0 hKaEJF"><h2 class="Box-sc-g0xbh4-0 XosP prc-Heading-Heading-6CmGO"><button style="--button-color:fg.muted" type="button" aria-label="Expand file tree" data-testid="expand-file-tree-button-mobile" class="Box-sc-g0xbh4-0 bCKfWo prc-Button-ButtonBase-c50BI" data-loading="false" data-size="medium" data-variant="invisible" aria-describedby=":Rld9lab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-arrow-left" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M7.78 12.53a.75.75 0 0 1-1.06 0L2.47 8.28a.75.75 0 0 1 0-1.06l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L4.81 7h7.44a.75.75 0 0 1 0 1.5H4.81l2.97 2.97a.75.75 0 0 1 0 1.06Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x">Files</span></span></button><span role="tooltip" aria-label="Expand file tree" id="expand-button-file-tree-button" class="Tooltip__TooltipBase-sc-17tf59c-0 hWlpPn tooltipped-se"><button data-component="IconButton" type="button" data-testid="expand-file-tree-button" aria-controls="repos-file-tree" class="prc-Button-ButtonBase-c50BI position-relative ExpandFileTreeButton-module__expandButton--gL4is ExpandFileTreeButton-module__filesButtonBreakpoint--WfX9t fgColor-muted prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="invisible" aria-describedby=":R35d9lab:-loading-announcement" aria-labelledby="expand-button-file-tree-button"><svg aria-hidden="true" focusable="false" class="octicon octicon-sidebar-collapse" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M6.823 7.823a.25.25 0 0 1 0 .354l-2.396 2.396A.25.25 0 0 1 4 10.396V5.604a.25.25 0 0 1 .427-.177Z"></path><path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25H9.5v-13H1.75a.25.25 0 0 0-.25.25ZM11 14.5h3.25a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H11Z"></path></svg></button></span><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button></h2></div><div class="react-code-view-header-mb--narrow mr-2"><button type="button" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-label="main branch" data-testid="anchor-button" class="Box-sc-g0xbh4-0 dmxRgG prc-Button-ButtonBase-c50BI ref-selector-class" data-loading="false" data-size="medium" data-variant="default" aria-describedby="branch-picker-repos-header-ref-selector-wide-loading-announcement" id="branch-picker-repos-header-ref-selector-wide"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x"><div class="Box-sc-g0xbh4-0 bZBlpz"><div class="Box-sc-g0xbh4-0 lhTYNA"><svg aria-hidden="true" focusable="false" class="octicon octicon-git-branch" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg></div><div class="Box-sc-g0xbh4-0 dbrgmi ref-selector-button-text-container"><span class="Box-sc-g0xbh4-0 bmcJak prc-Text-Text-0ima0"> <!-- -->main</span></div></div></span><span data-component="trailingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-triangle-down" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></span></span></button><button hidden="" data-hotkey-scope="read-only-cursor-text-area"></button></div><div class="Box-sc-g0xbh4-0 dHJiml react-code-view-header-mb--narrow"><div class="Box-sc-g0xbh4-0 cEytCf"><nav data-testid="breadcrumbs" aria-labelledby="repos-header-breadcrumb-heading" id="repos-header-breadcrumb" class="Box-sc-g0xbh4-0 fzFXnm"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading" id="repos-header-breadcrumb-heading">Breadcrumbs</h2><ol class="Box-sc-g0xbh4-0 iMnkmv"><li class="Box-sc-g0xbh4-0 ghzDag"><a class="Box-sc-g0xbh4-0 kHuKdh prc-Link-Link-85e08" sx="[object Object]" data-testid="breadcrumbs-repo-link" href="/python/peps/tree/main">peps</a></li><li class="Box-sc-g0xbh4-0 ghzDag"><span class="Box-sc-g0xbh4-0 hzJBof prc-Text-Text-0ima0" aria-hidden="true">/</span><a class="Box-sc-g0xbh4-0 kgiVEz prc-Link-Link-85e08" sx="[object Object]" href="/python/peps/tree/main/peps">peps</a></li></ol></nav><div data-testid="breadcrumbs-filename" class="Box-sc-g0xbh4-0 ghzDag"><span class="Box-sc-g0xbh4-0 hzJBof prc-Text-Text-0ima0" aria-hidden="true">/</span><h1 class="Box-sc-g0xbh4-0 jGhzSQ prc-Heading-Heading-6CmGO" tabindex="-1" id="file-name-id">pep-0622.rst</h1></div><button data-component="IconButton" type="button" class="prc-Button-ButtonBase-c50BI ml-2 prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="small" data-variant="invisible" aria-describedby=":Rftd9lab:-loading-announcement" aria-labelledby=":R1td9lab:"><svg aria-hidden="true" focusable="false" class="octicon octicon-copy" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></button><span class="CopyToClipboardButton-module__tooltip--Dq1IB prc-TooltipV2-Tooltip-cYMVY" data-direction="nw" aria-label="Copy path" aria-hidden="true" id=":R1td9lab:">Copy path</span></div></div></div><div class="react-code-view-header-element--wide"><div class="Box-sc-g0xbh4-0 faNtbn"><div class="d-flex gap-2"> <div><div class="Box-sc-g0xbh4-0 fmQaBv"><span class="Box-sc-g0xbh4-0 vcvyP TextInput-wrapper prc-components-TextInputWrapper-i1ofR prc-components-TextInputBaseWrapper-ueK9q" data-leading-visual="true" data-trailing-visual="true" aria-busy="false"><span class="TextInput-icon" id=":Rb66d9lab:" aria-hidden="true"><svg aria-hidden="true" focusable="false" class="octicon octicon-search" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg></span><input type="text" aria-label="Go to file" role="combobox" aria-controls="file-results-list" aria-expanded="false" aria-haspopup="dialog" autoCorrect="off" spellcheck="false" placeholder="Go to file" aria-describedby=":Rb66d9lab: :Rb66d9labH1:" data-component="input" class="prc-components-Input-Ic-y8" value=""/><span class="TextInput-icon" id=":Rb66d9labH1:" aria-hidden="true"></span></span></div><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden=""></button></div><button type="button" class="Box-sc-g0xbh4-0 dwNhzn prc-Button-ButtonBase-c50BI" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="default" aria-describedby=":R5a6d9lab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x">Blame</span></span></button><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><button data-component="IconButton" type="button" aria-label="More file actions" title="More file actions" data-testid="more-file-actions-button-nav-menu-wide" aria-haspopup="true" aria-expanded="false" tabindex="0" class="Box-sc-g0xbh4-0 fGwBZA prc-Button-ButtonBase-c50BI js-blob-dropdown-click prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="default" aria-describedby=":R2a6d9lab:-loading-announcement" id=":R2a6d9lab:"><svg aria-hidden="true" focusable="false" class="octicon octicon-kebab-horizontal" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg></button> </div></div></div><div class="react-code-view-header-element--narrow"><div class="Box-sc-g0xbh4-0 faNtbn"><div class="d-flex gap-2"> <button type="button" class="Box-sc-g0xbh4-0 dwNhzn prc-Button-ButtonBase-c50BI" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="default" aria-describedby=":R5a7d9lab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x">Blame</span></span></button><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><button data-component="IconButton" type="button" aria-label="More file actions" title="More file actions" data-testid="more-file-actions-button-nav-menu-narrow" aria-haspopup="true" aria-expanded="false" tabindex="0" class="Box-sc-g0xbh4-0 fGwBZA prc-Button-ButtonBase-c50BI js-blob-dropdown-click prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="default" aria-describedby=":R2a7d9lab:-loading-announcement" id=":R2a7d9lab:"><svg aria-hidden="true" focusable="false" class="octicon octicon-kebab-horizontal" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg></button> </div></div></div></div></div></div></div></div><div class="Box-sc-g0xbh4-0 dJxjrT react-code-view-bottom-padding"> <div class="Box-sc-g0xbh4-0 eFxKDQ"></div> <!-- --> <!-- --> </div><div class="Box-sc-g0xbh4-0 dJxjrT"> <!-- --> <!-- --> <div class="d-flex flex-column border rounded-2 mb-3 pl-1"><div class="Box-sc-g0xbh4-0 dzCJzi"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading">Latest commit</h2><div style="width:120px" class="Skeleton Skeleton--text" data-testid="loading"> </div><div class="d-flex flex-shrink-0 gap-2"><div data-testid="latest-commit-details" class="d-none d-sm-flex flex-items-center"></div><div class="d-flex gap-2"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading">History</h2><a href="/python/peps/commits/main/peps/pep-0622.rst" class="prc-Button-ButtonBase-c50BI d-none d-lg-flex LinkButton-module__code-view-link-button--xvCGA flex-items-center fgColor-default" data-loading="false" data-size="small" data-variant="invisible" aria-describedby=":R5dlal9lab:-loading-announcement"><span data-component="buttonContent" data-align="center" class="prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-history" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x"><span class="fgColor-default">History</span></span></span></a><div class="d-sm-none"></div><div class="d-flex d-lg-none"><span role="tooltip" aria-label="History" id="history-icon-button-tooltip" class="Tooltip__TooltipBase-sc-17tf59c-0 hWlpPn tooltipped-n"><a href="/python/peps/commits/main/peps/pep-0622.rst" class="prc-Button-ButtonBase-c50BI LinkButton-module__code-view-link-button--xvCGA flex-items-center fgColor-default" data-loading="false" data-size="small" data-variant="invisible" aria-describedby=":Rpdlal9lab:-loading-announcement history-icon-button-tooltip"><span data-component="buttonContent" data-align="center" class="prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-history" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m.427 1.927 1.215 1.215a8.002 8.002 0 1 1-1.6 5.685.75.75 0 1 1 1.493-.154 6.5 6.5 0 1 0 1.18-4.458l1.358 1.358A.25.25 0 0 1 3.896 6H.25A.25.25 0 0 1 0 5.75V2.104a.25.25 0 0 1 .427-.177ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"></path></svg></span></span></a></span></div></div></div></div></div><div class="Box-sc-g0xbh4-0 ldRxiI"><div class="Box-sc-g0xbh4-0 fVkfyA container"><div class="Box-sc-g0xbh4-0 gNAmSV react-code-size-details-banner"><div class="Box-sc-g0xbh4-0 jNEwzY react-code-size-details-banner"><div class="Box-sc-g0xbh4-0 bsDwxw text-mono"><div title="86.4 KB" data-testid="blob-size" class="Truncate__StyledTruncate-sc-23o1d2-0 eAtkQz"><span>2277 lines (1747 loc) · 86.4 KB</span></div></div></div></div><div class="Box-sc-g0xbh4-0 jdLMhu react-blob-view-header-sticky" id="repos-sticky-header"><div class="Box-sc-g0xbh4-0 tOISc"><div class="react-blob-sticky-header"><div class="Box-sc-g0xbh4-0 hqwSEx"><div class="Box-sc-g0xbh4-0 bDVoEr"><div class="Box-sc-g0xbh4-0 kYLlPM"><div class="Box-sc-g0xbh4-0 gYjEmn"><button type="button" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-label="main branch" data-testid="anchor-button" class="Box-sc-g0xbh4-0 dmxRgG prc-Button-ButtonBase-c50BI ref-selector-class" data-loading="false" data-size="medium" data-variant="default" aria-describedby="branch-picker-repos-header-ref-selector-loading-announcement" id="branch-picker-repos-header-ref-selector"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x"><div class="Box-sc-g0xbh4-0 bZBlpz"><div class="Box-sc-g0xbh4-0 lhTYNA"><svg aria-hidden="true" focusable="false" class="octicon octicon-git-branch" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg></div><div class="Box-sc-g0xbh4-0 dbrgmi ref-selector-button-text-container"><span class="Box-sc-g0xbh4-0 bmcJak prc-Text-Text-0ima0"> <!-- -->main</span></div></div></span><span data-component="trailingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-triangle-down" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></span></span></button><button hidden="" data-hotkey-scope="read-only-cursor-text-area"></button></div><div class="Box-sc-g0xbh4-0 kGqOLL"><div class="Box-sc-g0xbh4-0 fHind"><nav data-testid="breadcrumbs" aria-labelledby="sticky-breadcrumb-heading" id="sticky-breadcrumb" class="Box-sc-g0xbh4-0 fzFXnm"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading" id="sticky-breadcrumb-heading">Breadcrumbs</h2><ol class="Box-sc-g0xbh4-0 iMnkmv"><li class="Box-sc-g0xbh4-0 ghzDag"><a class="Box-sc-g0xbh4-0 kHuKdh prc-Link-Link-85e08" sx="[object Object]" data-testid="breadcrumbs-repo-link" href="/python/peps/tree/main">peps</a></li><li class="Box-sc-g0xbh4-0 ghzDag"><span class="Box-sc-g0xbh4-0 oDtgN prc-Text-Text-0ima0" aria-hidden="true">/</span><a class="Box-sc-g0xbh4-0 kgiVEz prc-Link-Link-85e08" sx="[object Object]" href="/python/peps/tree/main/peps">peps</a></li></ol></nav><div data-testid="breadcrumbs-filename" class="Box-sc-g0xbh4-0 ghzDag"><span class="Box-sc-g0xbh4-0 oDtgN prc-Text-Text-0ima0" aria-hidden="true">/</span><h1 class="Box-sc-g0xbh4-0 dnZoUW prc-Heading-Heading-6CmGO" tabindex="-1" id="sticky-file-name-id">pep-0622.rst</h1></div></div></div></div><button style="--button-color:fg.default" type="button" class="Box-sc-g0xbh4-0 jRZWlf prc-Button-ButtonBase-c50BI" data-loading="false" data-size="small" data-variant="invisible" aria-describedby=":Riptal9lab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="leadingVisual" class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB"><svg aria-hidden="true" focusable="false" class="octicon octicon-arrow-up" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M3.47 7.78a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0l4.25 4.25a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018L9 4.81v7.44a.75.75 0 0 1-1.5 0V4.81L4.53 7.78a.75.75 0 0 1-1.06 0Z"></path></svg></span><span data-component="text" class="prc-Button-Label-pTQ3x">Top</span></span></button></div></div></div><div class="Box-sc-g0xbh4-0 kTvpNk"><h2 class="sr-only ScreenReaderHeading-module__userSelectNone--vW4Cq prc-Heading-Heading-6CmGO" data-testid="screen-reader-heading">File metadata and controls</h2><div class="Box-sc-g0xbh4-0 iNMjfP"><ul aria-label="File view" class="Box-sc-g0xbh4-0 gtTaSn prc-SegmentedControl-SegmentedControl-e7570" data-size="small"><li class="Box-sc-g0xbh4-0 dXYHoy prc-SegmentedControl-Item-7Aq6h" data-selected="true"><button aria-current="true" class="prc-SegmentedControl-Button-ojWXD" type="button"><span class="prc-SegmentedControl-Content-gnQ4n"><div class="Box-sc-g0xbh4-0 prc-SegmentedControl-Text-c5gSh" data-text="Preview">Preview</div></span></button></li><li class="Box-sc-g0xbh4-0 jBWIdY prc-SegmentedControl-Item-7Aq6h"><button aria-current="false" class="prc-SegmentedControl-Button-ojWXD" type="button"><span class="prc-SegmentedControl-Content-gnQ4n"><div class="Box-sc-g0xbh4-0 prc-SegmentedControl-Text-c5gSh" data-text="Code">Code</div></span></button></li><li class="Box-sc-g0xbh4-0 jBWIdY prc-SegmentedControl-Item-7Aq6h"><button aria-current="false" class="prc-SegmentedControl-Button-ojWXD" type="button"><span class="prc-SegmentedControl-Content-gnQ4n"><div class="Box-sc-g0xbh4-0 prc-SegmentedControl-Text-c5gSh" data-text="Blame">Blame</div></span></button></li></ul><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><div class="Box-sc-g0xbh4-0 jNEwzY react-code-size-details-in-header"><div class="Box-sc-g0xbh4-0 bsDwxw text-mono"><div title="86.4 KB" data-testid="blob-size" class="Truncate__StyledTruncate-sc-23o1d2-0 eAtkQz"><span>2277 lines (1747 loc) · 86.4 KB</span></div></div></div></div><div class="Box-sc-g0xbh4-0 kcLCKF"><div class="Box-sc-g0xbh4-0 kVWtTz react-blob-header-edit-and-raw-actions"><div class="Box-sc-g0xbh4-0 prc-ButtonGroup-ButtonGroup-vcMeG"><div><a href="https://github.com/python/peps/raw/refs/heads/main/peps/pep-0622.rst" data-testid="raw-button" class="Box-sc-g0xbh4-0 gWqxTd prc-Button-ButtonBase-c50BI" data-loading="false" data-no-visuals="true" data-size="small" data-variant="default" aria-describedby=":R5csptal9lab:-loading-announcement"><span data-component="buttonContent" class="Box-sc-g0xbh4-0 gUkoLg prc-Button-ButtonContent-HKbr-"><span data-component="text" class="prc-Button-Label-pTQ3x">Raw</span></span></a></div><div><button data-component="IconButton" type="button" aria-label="Copy raw content" data-testid="copy-raw-button" class="prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="small" data-variant="default" aria-describedby=":Rpcsptal9lab:-loading-announcement"><svg aria-hidden="true" focusable="false" class="octicon octicon-copy" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></button></div><div><span role="tooltip" aria-label="Download raw file" id=":Rdcsptal9lab:" class="Tooltip__TooltipBase-sc-17tf59c-0 hWlpPn tooltipped-n"><button data-component="IconButton" type="button" aria-label="Download raw content" data-testid="download-raw-button" class="Box-sc-g0xbh4-0 ivobqY prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="small" data-variant="default" aria-describedby=":Rtcsptal9lab:-loading-announcement"><svg aria-hidden="true" focusable="false" class="octicon octicon-download" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"></path><path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"></path></svg></button></span></div></div><button hidden="" data-testid="raw-button-shortcut" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden="" data-testid="copy-raw-button-shortcut" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden="" data-testid="download-raw-button-shortcut" data-hotkey-scope="read-only-cursor-text-area"></button></div><button data-component="IconButton" type="button" aria-label="Outline" aria-pressed="false" class="Box-sc-g0xbh4-0 iNRSob prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="small" data-variant="invisible" aria-describedby=":R6sptal9lab:-loading-announcement"><svg aria-hidden="true" focusable="false" class="octicon octicon-list-unordered" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M5.75 2.5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5Zm0 5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5Zm0 5h8.5a.75.75 0 0 1 0 1.5h-8.5a.75.75 0 0 1 0-1.5ZM2 14a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-6a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM2 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg></button><div class="react-blob-header-edit-and-raw-actions-combined"><button data-component="IconButton" type="button" aria-label="Edit and raw actions" title="More file actions" data-testid="more-file-actions-button" aria-haspopup="true" aria-expanded="false" tabindex="0" class="Box-sc-g0xbh4-0 ffkqe prc-Button-ButtonBase-c50BI js-blob-dropdown-click prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="small" data-variant="invisible" aria-describedby=":Rnsptal9lab:-loading-announcement" id=":Rnsptal9lab:"><svg aria-hidden="true" focusable="false" class="octicon octicon-kebab-horizontal" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg></button></div></div></div></div><div></div></div><div class="Box-sc-g0xbh4-0 hGyMdv"><section aria-labelledby="file-name-id-wide file-name-id-mobile" class="Box-sc-g0xbh4-0 fGqKFv"><div class="Box-sc-g0xbh4-0 eoaCFS js-snippet-clipboard-copy-unpositioned undefined" data-hpc="true"><article class="markdown-body entry-content container-lg" itemprop="text"><p dir="auto">PEP: 622 Title: Structural Pattern Matching Author: Brandt Bucher &lt;<a href="mailto:brandt@python.org">brandt@python.org</a>&gt;,</p> <blockquote> Daniel F Moisset &lt;<a href="mailto:dfmoisset@gmail.com">dfmoisset@gmail.com</a>&gt;, Tobias Kohn &lt;<a href="mailto:kohnt@tobiaskohn.ch">kohnt@tobiaskohn.ch</a>&gt;, Ivan Levkivskyi &lt;<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>&gt;, Guido van Rossum &lt;<a href="mailto:guido@python.org">guido@python.org</a>&gt;, Talin &lt;<a href="mailto:viridia@gmail.com">viridia@gmail.com</a>&gt;</blockquote> <p dir="auto">BDFL-Delegate: Discussions-To: <a href="mailto:python-dev@python.org">python-dev@python.org</a> Status: Superseded Type: Standards Track Created: 23-Jun-2020 Python-Version: 3.10 Post-History: 23-Jun-2020, 08-Jul-2020 Superseded-By: 634</p> <a name="user-content-abstract"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Abstract</h2><a id="user-content-abstract" class="anchor" aria-label="Permalink: Abstract" href="#abstract"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This PEP proposes to add a <strong>pattern matching statement</strong> to Python, inspired by similar syntax found in Scala, Erlang, and other languages.</p> <a name="user-content-patterns-and-shapes"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Patterns and shapes</h3><a id="user-content-patterns-and-shapes" class="anchor" aria-label="Permalink: Patterns and shapes" href="#patterns-and-shapes"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The <strong>pattern syntax</strong> builds on Python’s existing syntax for sequence unpacking (e.g., <code>a, b = value</code>).</p> <p dir="auto">A <code>match</code> statement compares a value (the <strong>subject</strong>) to several different shapes (the <strong>patterns</strong>) until a shape fits. Each pattern describes the type and structure of the accepted values as well as the variables where to capture its contents.</p> <p dir="auto">Patterns can specify the shape to be:</p> <ul dir="auto"> <li>a sequence to be unpacked, as already mentioned</li> <li>a mapping with specific keys</li> <li>an instance of a given class with (optionally) specific attributes</li> <li>a specific value</li> <li>a wildcard</li> </ul> <p dir="auto">Patterns can be composed in several ways.</p> <a name="user-content-syntax"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Syntax</h3><a id="user-content-syntax" class="anchor" aria-label="Permalink: Syntax" href="#syntax"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Syntactically, a <code>match</code> statement contains:</p> <ul dir="auto"> <li>a <em>subject</em> expression</li> <li>one or more <code>case</code> clauses</li> </ul> <p dir="auto">Each <code>case</code> clause specifies:</p> <ul dir="auto"> <li>a pattern (the overall shape to be matched)</li> <li>an optional “guard” (a condition to be checked if the pattern matches)</li> <li>a code block to be executed if the case clause is selected</li> </ul> <a name="user-content-motivation"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Motivation</h3><a id="user-content-motivation" class="anchor" aria-label="Permalink: Motivation" href="#motivation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The rest of the PEP:</p> <ul dir="auto"> <li>motivates why we believe pattern matching makes a good addition to Python</li> <li>explains our design choices</li> <li>contains a precise syntactic and runtime specification</li> <li>gives guidance for static type checkers (and one small addition to the <code>typing</code> module)</li> <li>discusses the main objections and alternatives that have been brought up during extensive discussion of the proposal, both within the group of authors and in the python-dev community</li> </ul> <p dir="auto">Finally, we discuss some possible extensions that might be considered in the future, once the community has ample experience with the currently proposed syntax and semantics.</p> <a name="user-content-overview"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Overview</h2><a id="user-content-overview" class="anchor" aria-label="Permalink: Overview" href="#overview"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Patterns are a new syntactical category with their own rules and special cases. Patterns mix input (given values) and output (captured variables) in novel ways. They may take a little time to use effectively. The authors have provided a brief introduction to the basic concepts here. Note that this section is not intended to be complete or entirely accurate.</p> <a name="user-content-pattern-a-new-syntactic-construct-and-destructuring"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Pattern, a new syntactic construct, and destructuring</h3><a id="user-content-pattern-a-new-syntactic-construct-and-destructuring" class="anchor" aria-label="Permalink: Pattern, a new syntactic construct, and destructuring" href="#pattern-a-new-syntactic-construct-and-destructuring"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A new syntactic construct called <strong>pattern</strong> is introduced in this PEP. Syntactically, patterns look like a subset of expressions. The following are examples of patterns:</p> <ul dir="auto"> <li><code>[first, second, *rest]</code></li> <li><code>Point2d(x, 0)</code></li> <li><code>{"name": "Bruce", "age": age}</code></li> <li><code>42</code></li> </ul> <p dir="auto">The above expressions may look like examples of object construction with a constructor which takes some values as parameters and builds an object from those components.</p> <p dir="auto">When viewed as a pattern, the above patterns mean the inverse operation of construction, which we call <strong>destructuring</strong>. <strong>Destructuring</strong> takes a subject value and extracts its components.</p> <p dir="auto">The syntactic similarity between object construction and destructuring is intentional. It also follows the existing Pythonic style of contexts which makes assignment targets (write contexts) look like expressions (read contexts).</p> <p dir="auto">Pattern matching never creates objects. This is in the same way that <code>[a, b] = my_list</code> doesn't create a new <code>[a, b]</code> list, nor reads the values of <code>a</code> and <code>b</code>.</p> <a name="user-content-matching-process"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Matching process</h3><a id="user-content-matching-process" class="anchor" aria-label="Permalink: Matching process" href="#matching-process"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">During this matching process, the structure of the pattern may not fit the subject, and matching <em>fails</em>.</p> <p dir="auto">For example, matching the pattern <code>Point2d(x, 0)</code> to the subject <code>Point2d(3, 0)</code> successfully matches. The match also <strong>binds</strong> the pattern's free variable <code>x</code> to the subject's value <code>3</code>.</p> <p dir="auto">As another example, if the subject is <code>[3, 0]</code>, the match fails because the subject's type <code>list</code> is not the pattern's <code>Point2d</code>.</p> <p dir="auto">As a third example, if the subject is <code>Point2d(3, 7)</code>, the match fails because the subject's second coordinate <code>7</code> is not the same as the pattern's <code>0</code>.</p> <p dir="auto">The <code>match</code> statement tries to match a single subject to each of the patterns in its <code>case</code> clauses. At the first successful match to a pattern in a <code>case</code> clause:</p> <ul dir="auto"> <li>the variables in the pattern are assigned, and</li> <li>a corresponding block is executed.</li> </ul> <p dir="auto">Each <code>case</code> clause can also specify an optional boolean condition, known as a <strong>guard</strong>.</p> <p dir="auto">Let's look at a more detailed example of a <code>match</code> statement. The <code>match</code> statement is used within a function to define the building of 3D points. In this example, the function can accept as input any of the following: tuple with 2 elements, tuple with 3 elements, an existing Point2d object or an existing Point3d object:</p> <pre>def make_point_3d(pt): match pt: case (x, y): return Point3d(x, y, 0) case (x, y, z): return Point3d(x, y, z) case Point2d(x, y): return Point3d(x, y, 0) case Point3d(_, _, _): return pt case _: raise TypeError("not a point we support") </pre> <p dir="auto">Without pattern matching, this function's implementation would require several <code>isinstance()</code> checks, one or two <code>len()</code> calls, and a more convoluted control flow. The <code>match</code> example version and the traditional Python version without <code>match</code> translate into similar code under the hood. With familiarity of pattern matching, a user reading this function using <code>match</code> will likely find this version clearer than the traditional approach.</p> <a name="user-content-rationale-and-goals"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Rationale and Goals</h2><a id="user-content-rationale-and-goals" class="anchor" aria-label="Permalink: Rationale and Goals" href="#rationale-and-goals"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Python programs frequently need to handle data which varies in type, presence of attributes/keys, or number of elements. Typical examples are operating on nodes of a mixed structure like an AST, handling UI events of different types, processing structured input (like structured files or network messages), or “parsing” arguments for a function that can accept different combinations of types and numbers of parameters. In fact, the classic 'visitor' pattern is an example of this, done in an OOP style -- but matching makes it much less tedious to write.</p> <p dir="auto">Much of the code to do so tends to consist of complex chains of nested <code>if</code>/<code>elif</code> statements, including multiple calls to <code>len()</code>, <code>isinstance()</code> and index/key/attribute access. Inside those branches users sometimes need to destructure the data further to extract the required component values, which may be nested several objects deep.</p> <p dir="auto">Pattern matching as present in many other languages provides an elegant solution to this problem. These range from statically compiled functional languages like F# and Haskell, via mixed-paradigm languages like <a href="https://docs.scala-lang.org/tour/pattern-matching.html" rel="nofollow">Scala</a> and <a href="https://doc.rust-lang.org/reference/patterns.html" rel="nofollow">Rust</a>, to dynamic languages like Elixir and Ruby, and is under consideration for JavaScript. We are indebted to these languages for guiding the way to Pythonic pattern matching, as Python is indebted to so many other languages for many of its features: many basic syntactic features were inherited from C, exceptions from Modula-3, classes were inspired by C++, slicing came from Icon, regular expressions from Perl, decorators resemble Java annotations, and so on.</p> <p dir="auto">The usual logic for operating on heterogeneous data can be summarized in the following way:</p> <ul dir="auto"> <li>Some analysis is done on the <em>shape</em> (type and components) of the data: This could involve <code>isinstance()</code> or <code>len()</code> calls and/or extracting components (via indexing or attribute access) which are checked for specific values or conditions.</li> <li>If the shape is as expected, some more components are possibly extracted and some operation is done using the extracted values.</li> </ul> <p dir="auto">Take for example <a href="https://github.com/django/django/blob/5166097d7c80cab757e44f2d02f3d148fbbc2ff6/django/db/models/enums.py#L13">this piece of the Django web framework</a>:</p> <pre>if ( isinstance(value, (list, tuple)) and len(value) &gt; 1 and isinstance(value[-1], (Promise, str)) ): *value, label = value value = tuple(value) else: label = key.replace('_', ' ').title() </pre> <p dir="auto">We can see the shape analysis of the <code>value</code> at the top, following by the destructuring inside.</p> <p dir="auto">Note that shape analysis here involves checking the types both of the container and of one of its components, and some checks on its number of elements. Once we match the shape, we need to decompose the sequence. With the proposal in this PEP, we could rewrite that code into this:</p> <pre>match value: case [*v, label := (Promise() | str())] if v: value = tuple(v) case _: label = key.replace('_', ' ').title() </pre> <p dir="auto">This syntax makes much more explicit which formats are possible for the input data, and which components are extracted from where. You can see a pattern similar to list unpacking, but also type checking: the <code>Promise()</code> pattern is not an object construction, but represents anything that's an instance of <code>Promise</code>. The pattern operator <code>|</code> separates alternative patterns (not unlike regular expressions or EBNF grammars), and <code>_</code> is a wildcard. (Note that the match syntax used here will accept user-defined sequences, as well as lists and tuples.)</p> <p dir="auto">In some occasions, extraction of information is not as relevant as identifying structure. Take the following example from the <a href="https://github.com/python/cpython/blob/c4cacc8/Lib/lib2to3/fixer_util.py#L158">Python standard library</a>:</p> <pre>def is_tuple(node): if isinstance(node, Node) and node.children == [LParen(), RParen()]: return True return (isinstance(node, Node) and len(node.children) == 3 and isinstance(node.children[0], Leaf) and isinstance(node.children[1], Node) and isinstance(node.children[2], Leaf) and node.children[0].value == "(" and node.children[2].value == ")") </pre> <p dir="auto">This example shows an example of finding out the "shape" of the data without doing significant extraction. This code is not very easy to read, and the intended shape that this is trying to match is not evident. Compare with the updated code using the proposed syntax:</p> <pre>def is_tuple(node: Node) -&gt; bool: match node: case Node(children=[LParen(), RParen()]): return True case Node(children=[Leaf(value="("), Node(), Leaf(value=")")]): return True case _: return False </pre> <p dir="auto">Note that the proposed code will work without any modifications to the definition of <code>Node</code> and other classes here. As shown in the examples above, the proposal supports not just unpacking sequences, but also doing <code>isinstance</code> checks (like <code>LParen()</code> or <code>str()</code>), looking into object attributes (<code>Leaf(value="(")</code> for example) and comparisons with literals.</p> <p dir="auto">That last feature helps with some kinds of code which look more like the "switch" statement as present in other languages:</p> <pre>match response.status: case 200: do_something(response.data) # OK case 301 | 302: retry(response.location) # Redirect case 401: retry(auth=get_credentials()) # Login first case 426: sleep(DELAY) # Server is swamped, try after a bit retry() case _: raise RequestError("we couldn't get the data") </pre> <p dir="auto">Although this will work, it's not necessarily what the proposal is focused on, and the new syntax has been designed to best support the destructuring scenarios.</p> <p dir="auto">See the <a href="#syntax-and-semantics">syntax</a> sections below for a more detailed specification.</p> <p dir="auto">We propose that destructuring objects can be customized by a new special <code>__match_args__</code> attribute. As part of this PEP we specify the general API and its implementation for some standard library classes (including named tuples and dataclasses). See the <a href="#runtime-specification">runtime</a> section below.</p> <p dir="auto">Finally, we aim to provide comprehensive support for static type checkers and similar tools. For this purpose, we propose to introduce a <code>@typing.sealed</code> class decorator that will be a no-op at runtime but will indicate to static tools that all sub-classes of this class must be defined in the same module. This will allow effective static exhaustiveness checks, and together with dataclasses, will provide basic support for <a href="https://en.wikipedia.org/wiki/Algebraic_data_type" rel="nofollow">algebraic data types</a>. See the <a href="#static-checkers-specification">static checkers</a> section for more details.</p> <a name="user-content-syntax-and-semantics"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Syntax and Semantics</h2><a id="user-content-syntax-and-semantics" class="anchor" aria-label="Permalink: Syntax and Semantics" href="#syntax-and-semantics"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <a name="user-content-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Patterns</h3><a id="user-content-patterns" class="anchor" aria-label="Permalink: Patterns" href="#patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The <strong>pattern</strong> is a new syntactic construct, that could be considered a loose generalization of assignment targets. The key properties of a pattern are what types and shapes of subjects it accepts, what variables it captures and how it extracts them from the subject. For example, the pattern <code>[a, b]</code> matches only sequences of exactly 2 elements, extracting the first element into <code>a</code> and the second one into <code>b</code>.</p> <p dir="auto">This PEP defines several types of patterns. These are certainly not the only possible ones, so the design decision was made to choose a subset of functionality that is useful now but conservative. More patterns can be added later as this feature gets more widespread use. See the <a href="#rejected-ideas">rejected ideas</a> and <a href="#deferred-ideas">deferred ideas</a> sections for more details.</p> <p dir="auto">The patterns listed here are described in more detail below, but summarized together in this section for simplicity:</p> <ul dir="auto"> <li>A <strong>literal pattern</strong> is useful to filter constant values in a structure. It looks like a Python literal (including some values like <code>True</code>, <code>False</code> and <code>None</code>). It only matches objects equal to the literal, and never binds.</li> <li>A <strong>capture pattern</strong> looks like <code>x</code> and is equivalent to an identical assignment target: it always matches and binds the variable with the given (simple) name.</li> <li>The <strong>wildcard pattern</strong> is a single underscore: <code>_</code>. It always matches, but does not capture any variable (which prevents interference with other uses for <code>_</code> and allows for some optimizations).</li> <li>A <strong>constant value pattern</strong> works like the literal but for certain named constants. Note that it must be a qualified (dotted) name, given the possible ambiguity with a capture pattern. It looks like <code>Color.RED</code> and only matches values equal to the corresponding value. It never binds.</li> <li>A <strong>sequence pattern</strong> looks like <code>[a, *rest, b]</code> and is similar to a list unpacking. An important difference is that the elements nested within it can be any kind of patterns, not just names or sequences. It matches only sequences of appropriate length, as long as all the sub-patterns also match. It makes all the bindings of its sub-patterns.</li> <li>A <strong>mapping pattern</strong> looks like <code>{"user": u, "emails": [*es]}</code>. It matches mappings with at least the set of provided keys, and if all the sub-patterns match their corresponding values. It binds whatever the sub-patterns bind while matching with the values corresponding to the keys. Adding <code>**rest</code> at the end of the pattern to capture extra items is allowed.</li> <li>A <strong>class pattern</strong> is similar to the above but matches attributes instead of keys. It looks like <code>datetime.date(year=y, day=d)</code>. It matches instances of the given type, having at least the specified attributes, as long as the attributes match with the corresponding sub-patterns. It binds whatever the sub-patterns bind when matching with the values of the given attributes. An optional protocol also allows matching positional arguments.</li> <li>An <strong>OR pattern</strong> looks like <code>[*x] | {"elems": [*x]}</code>. It matches if any of its sub-patterns match. It uses the binding for the leftmost pattern that matched.</li> <li>A <strong>walrus pattern</strong> looks like <code>d := datetime(year=2020, month=m)</code>. It matches only if its sub-pattern also matches. It binds whatever the sub-pattern match does, and also binds the named variable to the entire object.</li> </ul> <a name="user-content-the-match-statement"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">The <code>match</code> statement</h3><a id="user-content-the-match-statement" class="anchor" aria-label="Permalink: The match statement" href="#the-match-statement"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A simplified, approximate grammar for the proposed syntax is:</p> <pre>... compound_statement: | if_stmt ... | match_stmt match_stmt: "match" expression ':' NEWLINE INDENT case_block+ DEDENT case_block: "case" pattern [guard] ':' block guard: 'if' expression pattern: walrus_pattern | or_pattern walrus_pattern: NAME ':=' or_pattern or_pattern: closed_pattern ('|' closed_pattern)* closed_pattern: | literal_pattern | capture_pattern | wildcard_pattern | constant_pattern | sequence_pattern | mapping_pattern | class_pattern </pre> <p dir="auto">See <a href="#appendix-a-full-grammar">Appendix A</a> for the full, unabridged grammar. The simplified grammars in this section are there for helping the reader, not as a full specification.</p> <p dir="auto">We propose that the match operation should be a statement, not an expression. Although in many languages it is an expression, being a statement better suits the general logic of Python syntax. See <a href="#rejected-ideas">rejected ideas</a> for more discussion. The allowed patterns are described in detail below in the <a href="#allowed-patterns">patterns</a> subsection.</p> <p dir="auto">The <code>match</code> and <code>case</code> keywords are proposed to be soft keywords, so that they are recognized as keywords at the beginning of a match statement or case block respectively, but are allowed to be used in other places as variable or argument names.</p> <p dir="auto">The proposed indentation structure is as following:</p> <pre>match some_expression: case pattern_1: ... case pattern_2: ... </pre> <p dir="auto">Here, <code>some_expression</code> represents the value that is being matched against, which will be referred to hereafter as the <em>subject</em> of the match.</p> <a name="user-content-match-semantics"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Match semantics</h3><a id="user-content-match-semantics" class="anchor" aria-label="Permalink: Match semantics" href="#match-semantics"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The proposed large scale semantics for choosing the match is to choose the first matching pattern and execute the corresponding suite. The remaining patterns are not tried. If there are no matching patterns, the statement 'falls through', and execution continues at the following statement.</p> <p dir="auto">Essentially this is equivalent to a chain of <code>if ... elif ... else</code> statements. Note that unlike for the previously proposed <code>switch</code> statement, the pre-computed dispatch dictionary semantics does not apply here.</p> <p dir="auto">There is no <code>default</code> or <code>else</code> case - instead the special wildcard <code>_</code> can be used (see the section on <a href="#capture-patterns">capture_pattern</a>) as a final 'catch-all' pattern.</p> <p dir="auto">Name bindings made during a successful pattern match outlive the executed suite and can be used after the match statement. This follows the logic of other Python statements that can bind names, such as <code>for</code> loop and <code>with</code> statement. For example:</p> <pre>match shape: case Point(x, y): ... case Rectangle(x, y, _, _): ... print(x, y) # This works </pre> <p dir="auto">During failed pattern matches, some sub-patterns may succeed. For example, while matching the value <code>[0, 1, 2]</code> with the pattern <code>(0, x, 1)</code>, the sub-pattern <code>x</code> may succeed if the list elements are matched from left to right. The implementation may choose to either make persistent bindings for those partial matches or not. User code including a <code>match</code> statement should not rely on the bindings being made for a failed match, but also shouldn't assume that variables are unchanged by a failed match. This part of the behavior is left intentionally unspecified so different implementations can add optimizations, and to prevent introducing semantic restrictions that could limit the extensibility of this feature.</p> <p dir="auto">Note that some pattern types below define more specific rules about when the binding is made.</p> <a name="user-content-allowed-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Allowed patterns</h3><a id="user-content-allowed-patterns" class="anchor" aria-label="Permalink: Allowed patterns" href="#allowed-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">We introduce the proposed syntax gradually. Here we start from the main building blocks. The following patterns are supported:</p> <a name="user-content-literal-patterns"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Literal Patterns</h4><a id="user-content-literal-patterns" class="anchor" aria-label="Permalink: Literal Patterns" href="#literal-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>literal_pattern: | number | string | 'None' | 'True' | 'False' </pre> <p dir="auto">A literal pattern consists of a simple literal like a string, a number, a Boolean literal (<code>True</code> or <code>False</code>), or <code>None</code>:</p> <pre>match number: case 0: print("Nothing") case 1: print("Just one") case 2: print("A couple") case -1: print("One less than nothing") case 1-1j: print("Good luck with that...") </pre> <p dir="auto">Literal pattern uses equality with literal on the right hand side, so that in the above example <code>number == 0</code> and then possibly <code>number == 1</code>, etc will be evaluated. Note that although technically negative numbers are represented using unary minus, they are considered literals for the purpose of pattern matching. Unary plus is not allowed. Binary plus and minus are allowed only to join a real number and an imaginary number to form a complex number, such as <code>1+1j</code>.</p> <p dir="auto">Note that because equality (<code>__eq__</code>) is used, and the equivalency between Booleans and the integers <code>0</code> and <code>1</code>, there is no practical difference between the following two:</p> <pre>case True: ... case 1: ... </pre> <p dir="auto">Triple-quoted strings are supported. Raw strings and byte strings are supported. F-strings are not allowed (since in general they are not really literals).</p> <a name="user-content-capture-patterns"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Capture Patterns</h4><a id="user-content-capture-patterns" class="anchor" aria-label="Permalink: Capture Patterns" href="#capture-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>capture_pattern: NAME </pre> <p dir="auto">A capture pattern serves as an assignment target for the matched expression:</p> <pre>match greeting: case "": print("Hello!") case name: print(f"Hi {name}!") </pre> <p dir="auto">Only a single name is allowed (a dotted name is a constant value pattern). A capture pattern always succeeds. A capture pattern appearing in a scope makes the name local to that scope. For example, using <code>name</code> after the above snippet may raise <code>UnboundLocalError</code> rather than <code>NameError</code>, if the <code>""</code> case clause was taken:</p> <pre>match greeting: case "": print("Hello!") case name: print(f"Hi {name}!") if name == "Santa": # &lt;-- might raise UnboundLocalError ... # but works fine if greeting was not empty </pre> <p dir="auto">While matching against each case clause, a name may be bound at most once, having two capture patterns with coinciding names is an error:</p> <pre>match data: case [x, x]: # Error! ... </pre> <p dir="auto">Note: one can still match on a collection with equal items using <a href="#guards">guards</a>. Also, <code>[x, y] | Point(x, y)</code> is a legal pattern because the two alternatives are never matched at the same time.</p> <p dir="auto">The single underscore (<code>_</code>) is not considered a <code>NAME</code> and treated specially as a <a href="#wildcard-pattern">wildcard pattern</a>.</p> <p dir="auto">Reminder: <code>None</code>, <code>False</code> and <code>True</code> are keywords denoting literals, not names.</p> <a name="user-content-wildcard-pattern"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Wildcard Pattern</h4><a id="user-content-wildcard-pattern" class="anchor" aria-label="Permalink: Wildcard Pattern" href="#wildcard-pattern"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>wildcard_pattern: "_" </pre> <p dir="auto">The single underscore (<code>_</code>) name is a special kind of pattern that always matches but <em>never</em> binds:</p> <pre>match data: case [_, _]: print("Some pair") print(_) # Error! </pre> <p dir="auto">Given that no binding is made, it can be used as many times as desired, unlike capture patterns.</p> <a name="user-content-constant-value-patterns"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Constant Value Patterns</h4><a id="user-content-constant-value-patterns" class="anchor" aria-label="Permalink: Constant Value Patterns" href="#constant-value-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>constant_pattern: NAME ('.' NAME)+ </pre> <p dir="auto">This is used to match against constants and enum values. Every dotted name in a pattern is looked up using normal Python name resolution rules, and the value is used for comparison by equality with the match subject (same as for literals):</p> <pre>from enum import Enum class Sides(str, Enum): SPAM = "Spam" EGGS = "eggs" ... match entree[-1]: case Sides.SPAM: # Compares entree[-1] == Sides.SPAM. response = "Have you got anything without Spam?" case side: # Assigns side = entree[-1]. response = f"Well, could I have their Spam instead of the {side} then?" </pre> <p dir="auto">Note that there is no way to use unqualified names as constant value patterns (they always denote variables to be captured). See <a href="#rejected-ideas">rejected ideas</a> for other syntactic alternatives that were considered for constant value patterns.</p> <a name="user-content-sequence-patterns"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Sequence Patterns</h4><a id="user-content-sequence-patterns" class="anchor" aria-label="Permalink: Sequence Patterns" href="#sequence-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>sequence_pattern: | '[' [values_pattern] ']' | '(' [value_pattern ',' [values pattern]] ')' values_pattern: ','.value_pattern+ ','? value_pattern: '*' capture_pattern | pattern </pre> <p dir="auto">A sequence pattern follows the same semantics as unpacking assignment. Like unpacking assignment, both tuple-like and list-like syntax can be used, with identical semantics. Each element can be an arbitrary pattern; there may also be at most one <code>*name</code> pattern to catch all remaining items:</p> <pre>match collection: case 1, [x, *others]: print("Got 1 and a nested sequence") case (1, x): print(f"Got 1 and {x}") </pre> <p dir="auto">To match a sequence pattern the subject must be an instance of <code>collections.abc.Sequence</code>, and it cannot be any kind of string (<code>str</code>, <code>bytes</code>, <code>bytearray</code>). It cannot be an iterator. For matching on a specific collection class, see class pattern below.</p> <p dir="auto">The <code>_</code> wildcard can be starred to match sequences of varying lengths. For example:</p> <ul dir="auto"> <li><code>[*_]</code> matches a sequence of any length.</li> <li><code>(_, _, *_)</code>, matches any sequence of length two or more.</li> <li><code>["a", *_, "z"]</code> matches any sequence of length two or more that starts with <code>"a"</code> and ends with <code>"z"</code>.</li> </ul> <a name="user-content-mapping-patterns"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Mapping Patterns</h4><a id="user-content-mapping-patterns" class="anchor" aria-label="Permalink: Mapping Patterns" href="#mapping-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>mapping_pattern: '{' [items_pattern] '}' items_pattern: ','.key_value_pattern+ ','? key_value_pattern: | (literal_pattern | constant_pattern) ':' or_pattern | '**' capture_pattern </pre> <p dir="auto">Mapping pattern is a generalization of iterable unpacking to mappings. Its syntax is similar to dictionary display but each key and value are patterns <code>"{" (pattern ":" pattern)+ "}"</code>. A <code>**rest</code> pattern is also allowed, to extract the remaining items. Only literal and constant value patterns are allowed in key positions:</p> <pre>import constants match config: case {"route": route}: process_route(route) case {constants.DEFAULT_PORT: sub_config, **rest}: process_config(sub_config, rest) </pre> <p dir="auto">The subject must be an instance of <code>collections.abc.Mapping</code>. Extra keys in the subject are ignored even if <code>**rest</code> is not present. This is different from sequence pattern, where extra items will cause a match to fail. But mappings are actually different from sequences: they have natural structural sub-typing behavior, i.e., passing a dictionary with extra keys somewhere will likely just work.</p> <p dir="auto">For this reason, <code>**_</code> is invalid in mapping patterns; it would always be a no-op that could be removed without consequence.</p> <p dir="auto">Matched key-value pairs must already be present in the mapping, and not created on-the-fly by <code>__missing__</code> or <code>__getitem__</code>. For example, <code>collections.defaultdict</code> instances will only match patterns with keys that were already present when the <code>match</code> block was entered.</p> <a name="user-content-class-patterns"></a> <div class="markdown-heading" dir="auto"><h4 tabindex="-1" class="heading-element" dir="auto">Class Patterns</h4><a id="user-content-class-patterns" class="anchor" aria-label="Permalink: Class Patterns" href="#class-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Simplified syntax:</p> <pre>class_pattern: | name_or_attr '(' ')' | name_or_attr '(' ','.pattern+ ','? ')' | name_or_attr '(' ','.keyword_pattern+ ','? ')' | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' keyword_pattern: NAME '=' or_pattern </pre> <p dir="auto">A class pattern provides support for destructuring arbitrary objects. There are two possible ways of matching on object attributes: by position like <code>Point(1, 2)</code>, and by name like <code>Point(x=1, y=2)</code>. These two can be combined, but a positional match cannot follow a match by name. Each item in a class pattern can be an arbitrary pattern. A simple example:</p> <pre>match shape: case Point(x, y): ... case Rectangle(x0, y0, x1, y1, painted=True): ... </pre> <p dir="auto">Whether a match succeeds or not is determined by the equivalent of an <code>isinstance</code> call. If the subject (<code>shape</code>, in the example) is not an instance of the named class (<code>Point</code> or <code>Rectangle</code>), the match fails. Otherwise, it continues (see details in the <a href="#runtime-specification">runtime</a> section).</p> <p dir="auto">The named class must inherit from <code>type</code>. It may be a single name or a dotted name (e.g. <code>some_mod.SomeClass</code> or <code>mod.pkg.Class</code>). The leading name must not be <code>_</code>, so e.g. <code>_(...)</code> and <code>_.C(...)</code> are invalid. Use <code>object(foo=_)</code> to check whether the matched object has an attribute <code>foo</code>.</p> <p dir="auto">By default, sub-patterns may only be matched by keyword for user-defined classes. In order to support positional sub-patterns, a custom <code>__match_args__</code> attribute is required. The runtime allows matching against arbitrarily nested patterns by chaining all of the instance checks and attribute lookups appropriately.</p> <a name="user-content-combining-multiple-patterns-or-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Combining multiple patterns (OR patterns)</h3><a id="user-content-combining-multiple-patterns-or-patterns" class="anchor" aria-label="Permalink: Combining multiple patterns (OR patterns)" href="#combining-multiple-patterns-or-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Multiple alternative patterns can be combined into one using <code>|</code>. This means the whole pattern matches if at least one alternative matches. Alternatives are tried from left to right and have a short-circuit property, subsequent patterns are not tried if one matched. Examples:</p> <pre>match something: case 0 | 1 | 2: print("Small number") case [] | [_]: print("A short sequence") case str() | bytes(): print("Something string-like") case _: print("Something else") </pre> <p dir="auto">The alternatives may bind variables, as long as each alternative binds the same set of variables (excluding <code>_</code>). For example:</p> <pre>match something: case 1 | x: # Error! ... case x | 1: # Error! ... case one := [1] | two := [2]: # Error! ... case Foo(arg=x) | Bar(arg=x): # Valid, both arms bind 'x' ... case [x] | x: # Valid, both arms bind 'x' ... </pre> <a name="user-content-guards"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Guards</h3><a id="user-content-guards" class="anchor" aria-label="Permalink: Guards" href="#guards"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Each <em>top-level</em> pattern can be followed by a <strong>guard</strong> of the form <code>if expression</code>. A case clause succeeds if the pattern matches and the guard evaluates to a true value. For example:</p> <pre>match input: case [x, y] if x &gt; MAX_INT and y &gt; MAX_INT: print("Got a pair of large numbers") case x if x &gt; MAX_INT: print("Got a large number") case [x, y] if x == y: print("Got equal items") case _: print("Not an outstanding input") </pre> <p dir="auto">If evaluating a guard raises an exception, it is propagated onwards rather than fail the case clause. Names that appear in a pattern are bound before the guard succeeds. So this will work:</p> <pre>values = [0] match values: case [x] if x: ... # This is not executed case _: ... print(x) # This will print "0" </pre> <p dir="auto">Note that guards are not allowed for nested patterns, so that <code>[x if x &gt; 0]</code> is a <code>SyntaxError</code> and <code>1 | 2 if 3 | 4</code> will be parsed as <code>(1 | 2) if (3 | 4)</code>.</p> <a name="user-content-walrus-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Walrus patterns</h3><a id="user-content-walrus-patterns" class="anchor" aria-label="Permalink: Walrus patterns" href="#walrus-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">It is often useful to match a sub-pattern <em>and</em> bind the corresponding value to a name. For example, it can be useful to write more efficient matches, or simply to avoid repetition. To simplify such cases, any pattern (other than the walrus pattern itself) can be preceded by a name and the walrus operator (<code>:=</code>). For example:</p> <pre>match get_shape(): case Line(start := Point(x, y), end) if start == end: print(f"Zero length line at {x}, {y}") </pre> <p dir="auto">The name on the left of the walrus operator can be used in a guard, in the match suite, or after the match statement. However, the name will <em>only</em> be bound if the sub-pattern succeeds. Another example:</p> <pre>match group_shapes(): case [], [point := Point(x, y), *other]: print(f"Got {point} in the second group") process_coordinates(x, y) ... </pre> <p dir="auto">Technically, most such examples can be rewritten using guards and/or nested match statements, but this will be less readable and/or will produce less efficient code. Essentially, most of the arguments in <a href="http://www.python.org/dev/peps/pep-0572" rel="nofollow">PEP 572</a> apply here equally.</p> <p dir="auto">The wildcard <code>_</code> is not a valid name here.</p> <a name="user-content-runtime-specification"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Runtime specification</h2><a id="user-content-runtime-specification" class="anchor" aria-label="Permalink: Runtime specification" href="#runtime-specification"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <a name="user-content-the-match-protocol"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">The Match Protocol</h3><a id="user-content-the-match-protocol" class="anchor" aria-label="Permalink: The Match Protocol" href="#the-match-protocol"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The equivalent of an <code>isinstance</code> call is used to decide whether an object matches a given class pattern and to extract the corresponding attributes. Classes requiring different matching semantics (such as duck-typing) can do so by defining <code>__instancecheck__</code> (a pre-existing metaclass hook) or by using <code>typing.Protocol</code>.</p> <p dir="auto">The procedure is as following:</p> <ul dir="auto"> <li>The class object for <code>Class</code> in <code>Class(&lt;sub-patterns&gt;)</code> is looked up and <code>isinstance(obj, Class)</code> is called, where <code>obj</code> is the value being matched. If false, the match fails.</li> <li>Otherwise, if any sub-patterns are given in the form of positional or keyword arguments, these are matched from left to right, as follows. The match fails as soon as a sub-pattern fails; if all sub-patterns succeed, the overall class pattern match succeeds.</li> <li>If there are match-by-position items and the class has a <code>__match_args__</code> attribute, the item at position <code>i</code> is matched against the value looked up by attribute <code>__match_args__[i]</code>. For example, a pattern <code>Point2d(5, 8)</code>, where <code>Point2d.__match_args__ == ["x", "y"]</code>, is translated (approximately) into <code>obj.x == 5 and obj.y == 8</code>.</li> <li>If there are more positional items than the length of <code>__match_args__</code>, a <code>TypeError</code> is raised.</li> <li>If the <code>__match_args__</code> attribute is absent on the matched class, and one or more positional item appears in a match, <code>TypeError</code> is also raised. We don't fall back on using <code>__slots__</code> or <code>__annotations__</code> -- "In the face of ambiguity, refuse the temptation to guess."</li> <li>If there are any match-by-keyword items the keywords are looked up as attributes on the subject. If the lookup succeeds the value is matched against the corresponding sub-pattern. If the lookup fails, the match fails.</li> </ul> <p dir="auto">Such a protocol favors simplicity of implementation over flexibility and performance. For other considered alternatives, see <a href="#extended-matching">extended matching</a>.</p> <p dir="auto">For the most commonly-matched built-in types (<code>bool</code>, <code>bytearray</code>, <code>bytes</code>, <code>dict</code>, <code>float</code>, <code>frozenset</code>, <code>int</code>, <code>list</code>, <code>set</code>, <code>str</code>, and <code>tuple</code>), a single positional sub-pattern is allowed to be passed to the call. Rather than being matched against any particular attribute on the subject, it is instead matched against the subject itself. This creates behavior that is useful and intuitive for these objects:</p> <ul dir="auto"> <li><code>bool(False)</code> matches <code>False</code> (but not <code>0</code>).</li> <li><code>tuple((0, 1, 2))</code> matches <code>(0, 1, 2)</code> (but not <code>[0, 1, 2]</code>).</li> <li><code>int(i)</code> matches any <code>int</code> and binds it to the name <code>i</code>.</li> </ul> <a name="user-content-overlapping-sub-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Overlapping sub-patterns</h3><a id="user-content-overlapping-sub-patterns" class="anchor" aria-label="Permalink: Overlapping sub-patterns" href="#overlapping-sub-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Certain classes of overlapping matches are detected at runtime and will raise exceptions. In addition to basic checks described in the previous subsection:</p> <ul dir="auto"> <li>The interpreter will check that two match items are not targeting the same attribute, for example <code>Point2d(1, 2, y=3)</code> is an error.</li> <li>It will also check that a mapping pattern does not attempt to match the same key more than once.</li> </ul> <a name="user-content-special-attribute-match-args"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Special attribute <code>__match_args__</code></h3><a id="user-content-special-attribute-__match_args__" class="anchor" aria-label="Permalink: Special attribute __match_args__" href="#special-attribute-__match_args__"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The <code>__match_args__</code> attribute is always looked up on the type object named in the pattern. If present, it must be a list or tuple of strings naming the allowed positional arguments.</p> <p dir="auto">In deciding what names should be available for matching, the recommended practice is that class patterns should be the mirror of construction; that is, the set of available names and their types should resemble the arguments to <code>__init__()</code>.</p> <p dir="auto">Only match-by-name will work by default, and classes should define <code>__match_args__</code> as a class attribute if they would like to support match-by-position. Additionally, dataclasses and named tuples will support match-by-position out of the box. See below for more details.</p> <a name="user-content-exceptions-and-side-effects"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Exceptions and side effects</h3><a id="user-content-exceptions-and-side-effects" class="anchor" aria-label="Permalink: Exceptions and side effects" href="#exceptions-and-side-effects"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">While matching each case, the <code>match</code> statement may trigger execution of other functions (for example <code>__getitem__()</code>, <code>__len__()</code> or a property). Almost every exception caused by those propagates outside of the match statement normally. The only case where an exception is not propagated is an <code>AttributeError</code> raised while trying to lookup an attribute while matching attributes of a Class Pattern; that case results in just a matching failure, and the rest of the statement proceeds normally.</p> <p dir="auto">The only side-effect carried on explicitly by the matching process is the binding of names. However, the process relies on attribute access, instance checks, <code>len()</code>, equality and item access on the subject and some of its components. It also evaluates constant value patterns and the left side of class patterns. While none of those typically create any side-effects, some of these objects could. This proposal intentionally leaves out any specification of what methods are called or how many times. User code relying on that behavior should be considered buggy.</p> <a name="user-content-the-standard-library"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">The standard library</h3><a id="user-content-the-standard-library" class="anchor" aria-label="Permalink: The standard library" href="#the-standard-library"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">To facilitate the use of pattern matching, several changes will be made to the standard library:</p> <ul dir="auto"> <li>Namedtuples and dataclasses will have auto-generated <code>__match_args__</code>.</li> <li>For dataclasses the order of attributes in the generated <code>__match_args__</code> will be the same as the order of corresponding arguments in the generated <code>__init__()</code> method. This includes the situations where attributes are inherited from a superclass.</li> </ul> <p dir="auto">In addition, a systematic effort will be put into going through existing standard library classes and adding <code>__match_args__</code> where it looks beneficial.</p> <a name="user-content-static-checkers-specification"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Static checkers specification</h2><a id="user-content-static-checkers-specification" class="anchor" aria-label="Permalink: Static checkers specification" href="#static-checkers-specification"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <a name="user-content-exhaustiveness-checks"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Exhaustiveness checks</h3><a id="user-content-exhaustiveness-checks" class="anchor" aria-label="Permalink: Exhaustiveness checks" href="#exhaustiveness-checks"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">From a reliability perspective, experience shows that missing a case when dealing with a set of possible data values leads to hard to debug issues, thus forcing people to add safety asserts like this:</p> <pre>def get_first(data: Union[int, list[int]]) -&gt; int: if isinstance(data, list) and data: return data[0] elif isinstance(data, int): return data else: assert False, "should never get here" </pre> <p dir="auto"><a href="http://www.python.org/dev/peps/pep-0484" rel="nofollow">PEP 484</a> specifies that static type checkers should support exhaustiveness in conditional checks with respect to enum values. <a href="http://www.python.org/dev/peps/pep-0586" rel="nofollow">PEP 586</a> later generalized this requirement to literal types.</p> <p dir="auto">This PEP further generalizes this requirement to arbitrary patterns. A typical situation where this applies is matching an expression with a union type:</p> <pre>def classify(val: Union[int, Tuple[int, int], List[int]]) -&gt; str: match val: case [x, y] if x &gt; 0 and y &gt; 0: return f"A pair of {x} and {y}" case [x, *other]: return f"A sequence starting with {x}" case int(): return f"Some integer" # Type-checking error: some cases unhandled. </pre> <p dir="auto">The exhaustiveness checks should also apply where both pattern matching and enum values are combined:</p> <pre>from enum import Enum from typing import Union class Level(Enum): BASIC = 1 ADVANCED = 2 PRO = 3 class User: name: str level: Level class Admin: name: str account: Union[User, Admin] match account: case Admin(name=name) | User(name=name, level=Level.PRO): ... case User(level=Level.ADVANCED): ... # Type-checking error: basic user unhandled </pre> <p dir="auto">Obviously, no <code>Matchable</code> protocol (in terms of <a href="http://www.python.org/dev/peps/pep-0544" rel="nofollow">PEP 544</a>) is needed, since every class is matchable and therefore is subject to the checks specified above.</p> <a name="user-content-sealed-classes-as-algebraic-data-types"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Sealed classes as algebraic data types</h3><a id="user-content-sealed-classes-as-algebraic-data-types" class="anchor" aria-label="Permalink: Sealed classes as algebraic data types" href="#sealed-classes-as-algebraic-data-types"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Quite often it is desirable to apply exhaustiveness to a set of classes without defining ad-hoc union types, which is itself fragile if a class is missing in the union definition. A design pattern where a group of record-like classes is combined into a union is popular in other languages that support pattern matching and is known under a name of <a href="https://en.wikipedia.org/wiki/Algebraic_data_type" rel="nofollow">algebraic data types</a>.</p> <p dir="auto">We propose to add a special decorator class <code>@sealed</code> to the <a href="#id2"><span id="user-content-id3">:py:mod:`typing`</span></a> module, that will have no effect at runtime, but will indicate to static type checkers that all subclasses (direct and indirect) of this class should be defined in the same module as the base class.</p> <p dir="auto">The idea is that since all subclasses are known, the type checker can treat the sealed base class as a union of all its subclasses. Together with dataclasses this allows a clean and safe support of algebraic data types in Python. Consider this example:</p> <pre>from dataclasses import dataclass from typing import sealed @sealed class Node: ... class Expression(Node): ... class Statement(Node): ... @dataclass class Name(Expression): name: str @dataclass class Operation(Expression): left: Expression op: str right: Expression @dataclass class Assignment(Statement): target: str value: Expression @dataclass class Print(Statement): value: Expression </pre> <p dir="auto">With such definition, a type checker can safely treat <code>Node</code> as <code>Union[Name, Operation, Assignment, Print]</code>, and also safely treat e.g. <code>Expression</code> as <code>Union[Name, Operation]</code>. So this will result in a type checking error in the below snippet, because <code>Name</code> is not handled (and type checker can give a useful error message):</p> <pre>def dump(node: Node) -&gt; str: match node: case Assignment(target, value): return f"{target} = {dump(value)}" case Print(value): return f"print({dump(value)})" case Operation(left, op, right): return f"({dump(left)} {op} {dump(right)})" </pre> <a name="user-content-type-erasure"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Type erasure</h3><a id="user-content-type-erasure" class="anchor" aria-label="Permalink: Type erasure" href="#type-erasure"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Class patterns are subject to runtime type erasure. Namely, although one can define a type alias <code>IntQueue = Queue[int]</code> so that a pattern like <code>IntQueue()</code> is syntactically valid, type checkers should reject such a match:</p> <pre>queue: Union[Queue[int], Queue[str]] match queue: case IntQueue(): # Type-checking error here ... </pre> <p dir="auto">Note that the above snippet actually fails at runtime with the current implementation of generic classes in the <code>typing</code> module, as well as with builtin generic classes in the recently accepted <a href="http://www.python.org/dev/peps/pep-0585" rel="nofollow">PEP 585</a>, because they prohibit <code>isinstance</code> checks.</p> <p dir="auto">To clarify, generic classes are not prohibited in general from participating in pattern matching, just that their type parameters can't be explicitly specified. It is still fine if sub-patterns or literals bind the type variables. For example:</p> <pre>from typing import Generic, TypeVar, Union T = TypeVar('T') class Result(Generic[T]): first: T other: list[T] result: Union[Result[int], Result[str]] match result: case Result(first=int()): ... # Type of result is Result[int] here case Result(other=["foo", "bar", *rest]): ... # Type of result is Result[str] here </pre> <a name="user-content-note-about-constants"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Note about constants</h3><a id="user-content-note-about-constants" class="anchor" aria-label="Permalink: Note about constants" href="#note-about-constants"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The fact that a capture pattern is always an assignment target may create unwanted consequences when a user by mistake tries to "match" a value against a constant instead of using the constant value pattern. As a result, at runtime such a match will always succeed and moreover override the value of the constant. It is important therefore that static type checkers warn about such situations. For example:</p> <pre>from typing import Final MAX_INT: Final = 2 ** 64 value = 0 match value: case MAX_INT: # Type-checking error here: cannot assign to final name print("Got big number") case _: print("Something else") </pre> <p dir="auto">Note that the CPython reference implementation also generates a <code>SyntaxWarning</code> message for this case.</p> <a name="user-content-precise-type-checking-of-star-matches"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Precise type checking of star matches</h3><a id="user-content-precise-type-checking-of-star-matches" class="anchor" aria-label="Permalink: Precise type checking of star matches" href="#precise-type-checking-of-star-matches"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Type checkers should perform precise type checking of star items in pattern matching giving them either a heterogeneous <code>list[T]</code> type, or a <code>TypedDict</code> type as specified by <a href="http://www.python.org/dev/peps/pep-0589" rel="nofollow">PEP 589</a>. For example:</p> <pre>stuff: Tuple[int, str, str, float] match stuff: case a, *b, 0.5: # Here a is int and b is list[str] ... </pre> <a name="user-content-performance-considerations"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Performance Considerations</h2><a id="user-content-performance-considerations" class="anchor" aria-label="Permalink: Performance Considerations" href="#performance-considerations"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Ideally, a <code>match</code> statement should have good runtime performance compared to an equivalent chain of if-statements. Although the history of programming languages is rife with examples of new features which increased engineer productivity at the expense of additional CPU cycles, it would be unfortunate if the benefits of <code>match</code> were counter-balanced by a significant overall decrease in runtime performance.</p> <p dir="auto">Although this PEP does not specify any particular implementation strategy, a few words about the prototype implementation and how it attempts to maximize performance are in order.</p> <p dir="auto">Basically, the prototype implementation transforms all of the <code>match</code> statement syntax into equivalent if/else blocks - or more accurately, into Python byte codes that have the same effect. In other words, all of the logic for testing instance types, sequence lengths, mapping keys and so on are inlined in place of the <code>match</code>.</p> <p dir="auto">This is not the only possible strategy, nor is it necessarily the best. For example, the instance checks could be memoized, especially if there are multiple instances of the same class type but with different arguments in a single match statement. It is also theoretically possible for a future implementation to process case clauses or sub-patterns in parallel using a decision tree rather than testing them one by one.</p> <a name="user-content-backwards-compatibility"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Backwards Compatibility</h2><a id="user-content-backwards-compatibility" class="anchor" aria-label="Permalink: Backwards Compatibility" href="#backwards-compatibility"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This PEP is fully backwards compatible: the <code>match</code> and <code>case</code> keywords are proposed to be (and stay!) soft keywords, so their use as variable, function, class, module or attribute names is not impeded at all.</p> <p dir="auto">This is important because <code>match</code> is the name of a popular and well-known function and method in the <code>re</code> module, which we have no desire to break or deprecate.</p> <p dir="auto">The difference between hard and soft keywords is that hard keywords are <em>always</em> reserved words, even in positions where they make no sense (e.g. <code>x = class + 1</code>), while soft keywords only get a special meaning in context. Since <a href="http://www.python.org/dev/peps/pep-0617" rel="nofollow">PEP 617</a> the parser backtracks, that means that on different attempts to parse a code fragment it could interpret a soft keyword differently.</p> <p dir="auto">For example, suppose the parser encounters the following input:</p> <pre>match [x, y]: </pre> <p dir="auto">The parser first attempts to parse this as an expression statement. It interprets <code>match</code> as a NAME token, and then considers <code>[x, y]</code> to be a double subscript. It then encounters the colon and has to backtrack, since an expression statement cannot be followed by a colon. The parser then backtracks to the start of the line and finds that <code>match</code> is a soft keyword allowed in this position. It then considers <code>[x, y]</code> to be a list expression. The colon then is just what the parser expected, and the parse succeeds.</p> <a name="user-content-impacts-on-third-party-tools"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Impacts on third-party tools</h2><a id="user-content-impacts-on-third-party-tools" class="anchor" aria-label="Permalink: Impacts on third-party tools" href="#impacts-on-third-party-tools"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">There are a lot of tools in the Python ecosystem that operate on Python source code: linters, syntax highlighters, auto-formatters, and IDEs. These will all need to be updated to include awareness of the <code>match</code> statement.</p> <p dir="auto">In general, these tools fall into one of two categories:</p> <p dir="auto"><strong>Shallow</strong> parsers don't try to understand the full syntax of Python, but instead scan the source code for specific known patterns. IDEs, such as Visual Studio Code, Emacs and TextMate, tend to fall in this category, since frequently the source code is invalid while being edited, and a strict approach to parsing would fail.</p> <p dir="auto">For these kinds of tools, adding knowledge of a new keyword is relatively easy, just an addition to a table, or perhaps modification of a regular expression.</p> <p dir="auto"><strong>Deep</strong> parsers understand the complete syntax of Python. An example of this is the auto-formatter <a href="https://black.readthedocs.io/en/stable/" rel="nofollow">Black</a>. A particular requirement with these kinds of tools is that they not only need to understand the syntax of the current version of Python, but older versions of Python as well.</p> <p dir="auto">The <code>match</code> statement uses a soft keyword, and it is one of the first major Python features to take advantage of the capabilities of the new PEG parser. This means that third-party parsers which are not 'PEG-compatible' will have a hard time with the new syntax.</p> <p dir="auto">It has been noted that a number of these third-party tools leverage common parsing libraries (Black for example uses a fork of the lib2to3 parser). It may be helpful to identify widely used parsing libraries (such as <a href="https://github.com/davidhalter/parso">parso</a> and <a href="https://github.com/Instagram/LibCST">libCST</a>) and upgrade them to be PEG compatible.</p> <p dir="auto">However, since this work would need to be done not only for the match statement, but for <em>any</em> new Python syntax that leverages the capabilities of the PEG parser, it is considered out of scope for this PEP. (Although it is suggested that this would make a fine Summer of Code project.)</p> <a name="user-content-reference-implementation"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Reference Implementation</h2><a id="user-content-reference-implementation" class="anchor" aria-label="Permalink: Reference Implementation" href="#reference-implementation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A <a href="https://github.com/brandtbucher/cpython/tree/patma">feature-complete CPython implementation</a> is available on GitHub.</p> <p dir="auto">An <a href="https://mybinder.org/v2/gh/gvanrossum/patma/master?urlpath=lab/tree/playground-622.ipynb" rel="nofollow">interactive playground</a> based on the above implementation was created using <a href="https://mybinder.org" rel="nofollow">Binder</a> and <a href="https://jupyter.org" rel="nofollow">Jupyter</a>.</p> <a name="user-content-example-code"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Example Code</h2><a id="user-content-example-code" class="anchor" aria-label="Permalink: Example Code" href="#example-code"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A small <a href="https://github.com/gvanrossum/patma/tree/master/examples">collection of example code</a> is available on GitHub.</p> <a name="user-content-rejected-ideas"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Rejected Ideas</h2><a id="user-content-rejected-ideas" class="anchor" aria-label="Permalink: Rejected Ideas" href="#rejected-ideas"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This general idea has been floating around for a pretty long time, and many back and forth decisions were made. Here we summarize many alternative paths that were taken but eventually abandoned.</p> <a name="user-content-don-t-do-this-pattern-matching-is-hard-to-learn"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Don't do this, pattern matching is hard to learn</h3><a id="user-content-dont-do-this-pattern-matching-is-hard-to-learn" class="anchor" aria-label="Permalink: Don't do this, pattern matching is hard to learn" href="#dont-do-this-pattern-matching-is-hard-to-learn"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">In our opinion, the proposed pattern matching is not more difficult than adding <code>isinstance()</code> and <code>getattr()</code> to iterable unpacking. Also, we believe the proposed syntax significantly improves readability for a wide range of code patterns, by allowing to express <em>what</em> one wants to do, rather than <em>how</em> to do it. We hope the few real code snippets we included in the PEP above illustrate this comparison well enough. For more real code examples and their translations see Ref. <a href="#id5" id="user-content-id4">[1]</a>.</p> <a name="user-content-don-t-do-this-use-existing-method-dispatching-mechanisms"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Don't do this, use existing method dispatching mechanisms</h3><a id="user-content-dont-do-this-use-existing-method-dispatching-mechanisms" class="anchor" aria-label="Permalink: Don't do this, use existing method dispatching mechanisms" href="#dont-do-this-use-existing-method-dispatching-mechanisms"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">We recognize that some of the use cases for the <code>match</code> statement overlap with what can be done with traditional object-oriented programming (OOP) design techniques using class inheritance. The ability to choose alternate behaviors based on testing the runtime type of a match subject might even seem heretical to strict OOP purists.</p> <p dir="auto">However, Python has always been a language that embraces a variety of programming styles and paradigms. Classic Python design idioms such as "duck"-typing go beyond the traditional OOP model.</p> <p dir="auto">We believe that there are important use cases where the use of <code>match</code> results in a cleaner and more maintainable architecture. These use cases tend to be characterized by a number of features:</p> <ul dir="auto"> <li>Algorithms which cut across traditional lines of data encapsulation. If an algorithm is processing heterogeneous elements of different types (such as evaluating or transforming an abstract syntax tree, or doing algebraic manipulation of mathematical symbols), forcing the user to implement the algorithm as individual methods on each element type results in logic that is smeared across the entire codebase instead of being neatly localized in one place.</li> <li>Program architectures where the set of possible data types is relatively stable, but there is an ever-expanding set of operations to be performed on those data types. Doing this in a strict OOP fashion requires constantly adding new methods to both the base class and subclasses to support the new methods, "polluting" the base class with lots of very specialized method definitions, and causing widespread disruption and churn in the code. By contrast, in a <code>match</code>-based dispatch, adding a new behavior merely involves writing a new <code>match</code> statement.</li> <li>OOP also does not handle dispatching based on the <em>shape</em> of an object, such as the length of a tuple, or the presence of an attribute -- instead any such dispatching decision must be encoded into the object's type. Shape-based dispatching is particularly interesting when it comes to handling "duck"-typed objects.</li> </ul> <p dir="auto">Where OOP is clearly superior is in the opposite case: where the set of possible operations is relatively stable and well-defined, but there is an ever-growing set of data types to operate on. A classic example of this is UI widget toolkits, where there is a fixed set of interaction types (repaint, mouse click, keypress, and so on), but the set of widget types is constantly expanding as developers invent new and creative user interaction styles. Adding a new kind of widget is a simple matter of writing a new subclass, whereas with a match-based approach you end up having to add a new case clause to many widespread match statements. We therefore don't recommend using <code>match</code> in such a situation.</p> <a name="user-content-allow-more-flexible-assignment-targets-instead"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Allow more flexible assignment targets instead</h3><a id="user-content-allow-more-flexible-assignment-targets-instead" class="anchor" aria-label="Permalink: Allow more flexible assignment targets instead" href="#allow-more-flexible-assignment-targets-instead"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">There was an idea to instead just generalize the iterable unpacking to much more general assignment targets, instead of adding a new kind of statement. This concept is known in some other languages as "irrefutable matches". We decided not to do this because inspection of real-life potential use cases showed that in vast majority of cases destructuring is related to an <code>if</code> condition. Also many of those are grouped in a series of exclusive choices.</p> <a name="user-content-make-it-an-expression"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Make it an expression</h3><a id="user-content-make-it-an-expression" class="anchor" aria-label="Permalink: Make it an expression" href="#make-it-an-expression"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">In most other languages pattern matching is represented by an expression, not statement. But making it an expression would be inconsistent with other syntactic choices in Python. All decision making logic is expressed almost exclusively in statements, so we decided to not deviate from this.</p> <a name="user-content-use-a-hard-keyword"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use a hard keyword</h3><a id="user-content-use-a-hard-keyword" class="anchor" aria-label="Permalink: Use a hard keyword" href="#use-a-hard-keyword"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">There were options to make <code>match</code> a hard keyword, or choose a different keyword. Although using a hard keyword would simplify life for simple-minded syntax highlighters, we decided not to use hard keyword for several reasons:</p> <ul dir="auto"> <li>Most importantly, the new parser doesn't require us to do this. Unlike with <code>async</code> that caused hardships with being a soft keyword for few releases, here we can make <code>match</code> a permanent soft keyword.</li> <li><code>match</code> is so commonly used in existing code, that it would break almost every existing program and will put a burden to fix code on many people who may not even benefit from the new syntax.</li> <li>It is hard to find an alternative keyword that would not be commonly used in existing programs as an identifier, and would still clearly reflect the meaning of the statement.</li> </ul> <a name="user-content-use-as-or-instead-of-case-for-case-clauses"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use <code>as</code> or <code>|</code> instead of <code>case</code> for case clauses</h3><a id="user-content-use-as-or--instead-of-case-for-case-clauses" class="anchor" aria-label="Permalink: Use as or | instead of case for case clauses" href="#use-as-or--instead-of-case-for-case-clauses"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The pattern matching proposed here is a combination of multi-branch control flow (in line with <code>switch</code> in Algol-derived languages or <code>cond</code> in Lisp) and object-deconstruction as found in functional languages. While the proposed keyword <code>case</code> highlights the multi-branch aspect, alternative keywords such as <code>as</code> would equally be possible, highlighting the deconstruction aspect. <code>as</code> or <code>with</code>, for instance, also have the advantage of already being keywords in Python. However, since <code>case</code> as a keyword can only occur as a leading keyword inside a <code>match</code> statement, it is easy for a parser to distinguish between its use as a keyword or as a variable.</p> <p dir="auto">Other variants would use a symbol like <code>|</code> or <code>=&gt;</code>, or go entirely without special marker.</p> <p dir="auto">Since Python is a statement-oriented language in the tradition of Algol, and as each composite statement starts with an identifying keyword, <code>case</code> seemed to be most in line with Python's style and traditions.</p> <a name="user-content-use-a-flat-indentation-scheme"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use a flat indentation scheme</h3><a id="user-content-use-a-flat-indentation-scheme" class="anchor" aria-label="Permalink: Use a flat indentation scheme" href="#use-a-flat-indentation-scheme"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">There was an idea to use an alternative indentation scheme, for example where every case clause would not be indented with respect to the initial <code>match</code> part:</p> <pre>match expression: case pattern_1: ... case pattern_2: ... </pre> <p dir="auto">The motivation is that although flat indentation saves some horizontal space, it may look awkward to an eye of a Python programmer, because everywhere else colon is followed by an indent. This will also complicate life for simple-minded code editors. Finally, the horizontal space issue can be alleviated by allowing "half-indent" (i.e. two spaces instead of four) for match statements.</p> <p dir="auto">In sample programs using <code>match</code>, written as part of the development of this PEP, a noticeable improvement in code brevity is observed, more than making up for the additional indentation level.</p> <p dir="auto">Another proposal considered was to use flat indentation but put the expression on the line after <code>match:</code>, like this:</p> <pre>match: expression case pattern_1: ... case pattern_2: ... </pre> <p dir="auto">This was ultimately rejected because the first block would be a novelty in Python's grammar: a block whose only content is a single expression rather than a sequence of statements.</p> <a name="user-content-alternatives-for-constant-value-pattern"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Alternatives for constant value pattern</h3><a id="user-content-alternatives-for-constant-value-pattern" class="anchor" aria-label="Permalink: Alternatives for constant value pattern" href="#alternatives-for-constant-value-pattern"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This is probably the trickiest item. Matching against some pre-defined constants is very common, but the dynamic nature of Python also makes it ambiguous with capture patterns. Five other alternatives were considered:</p> <ul dir="auto"> <li><p dir="auto">Use some implicit rules. For example, if a name was defined in the global scope, then it refers to a constant, rather than representing a capture pattern:</p> <pre># Here, the name "spam" must be defined in the global scope (and # not shadowed locally). "side" must be local. match entree[-1]: case spam: ... # Compares entree[-1] == spam. case side: ... # Assigns side = entree[-1]. </pre> <p dir="auto">This however can cause surprises and action at a distance if someone defines an unrelated coinciding name before the match statement.</p> </li> <li><p dir="auto">Use a rule based on the case of a name. In particular, if the name starts with a lowercase letter it would be a capture pattern, while if it starts with uppercase it would refer to a constant:</p> <pre>match entree[-1]: case SPAM: ... # Compares entree[-1] == SPAM. case side: ... # Assigns side = entree[-1]. </pre> <p dir="auto">This works well with the recommendations for naming constants from <a href="http://www.python.org/dev/peps/pep-0008" rel="nofollow">PEP 8</a>. The main objection is that there's no other part of core Python where the case of a name is semantically significant. In addition, Python allows identifiers to use different scripts, many of which (e.g. CJK) don't have a case distinction.</p> </li> <li><p dir="auto">Use extra parentheses to indicate lookup semantics for a given name. For example:</p> <pre>match entree[-1]: case (spam): ... # Compares entree[-1] == spam. case side: ... # Assigns side = entree[-1]. </pre> <p dir="auto">This may be a viable option, but it can create some visual noise if used often. Also honestly it looks pretty unusual, especially in nested contexts.</p> <p dir="auto">This also has the problem that we may want or need parentheses to disambiguate grouping in patterns, e.g. in <code>Point(x, y=(y := complex()))</code>.</p> </li> <li><p dir="auto">Introduce a special symbol, for example <code>.</code>, <code>?</code>, <code>$</code>, or <code>^</code> to indicate that a given name is a value to be matched against, not to be assigned to. An earlier version of this proposal used a leading-dot rule:</p> <pre>match entree[-1]: case .spam: ... # Compares entree[-1] == spam. case side: ... # Assigns side = entree[-1]. </pre> <p dir="auto">While potentially useful, it introduces strange-looking new syntax without making the pattern syntax any more expressive. Indeed, named constants can be made to work with the existing rules by converting them to <code>Enum</code> types, or enclosing them in their own namespace (considered by the authors to be one honking great idea):</p> <pre>match entree[-1]: case Sides.SPAM: ... # Compares entree[-1] == Sides.SPAM. case side: ... # Assigns side = entree[-1]. </pre> <p dir="auto">If needed, the leading-dot rule (or a similar variant) could be added back later with no backward-compatibility issues.</p> </li> <li><p dir="auto">There was also an idea to make lookup semantics the default, and require <code>$</code> or <code>?</code> to be used in capture patterns:</p> <pre>match entree[-1]: case spam: ... # Compares entree[-1] == spam. case side?: ... # Assigns side = entree[-1]. </pre> <p dir="auto">There are a few issues with this:</p> <ul dir="auto"> <li><p dir="auto">Capture patterns are more common in typical code, so it is undesirable to require special syntax for them.</p> </li> <li><p dir="auto">The authors are not aware of any other language that adorns captures in this way.</p> </li> <li><p dir="auto">None of the proposed syntaxes have any precedent in Python; no other place in Python that binds names (e.g. <code>import</code>, <code>def</code>, <code>for</code>) uses special marker syntax.</p> </li> <li><p dir="auto">It would break the syntactic parallels of the current grammar:</p> <pre>match coords: case ($x, $y): return Point(x, y) # Why not "Point($x, $y)"? </pre> </li> </ul> </li> </ul> <p dir="auto">In the end, these alternatives were rejected because of the mentioned drawbacks.</p> <a name="user-content-disallow-float-literals-in-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Disallow float literals in patterns</h3><a id="user-content-disallow-float-literals-in-patterns" class="anchor" aria-label="Permalink: Disallow float literals in patterns" href="#disallow-float-literals-in-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Because of the inexactness of floats, an early version of this proposal did not allow floating-point constants to be used as match patterns. Part of the justification for this prohibition is that Rust does this.</p> <p dir="auto">However, during implementation, it was discovered that distinguishing between float values and other types required extra code in the VM that would slow matches generally. Given that Python and Rust are very different languages with different user bases and underlying philosophies, it was felt that allowing float literals would not cause too much harm, and would be less surprising to users.</p> <a name="user-content-range-matching-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Range matching patterns</h3><a id="user-content-range-matching-patterns" class="anchor" aria-label="Permalink: Range matching patterns" href="#range-matching-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This would allow patterns such as <code>1...6</code>. However, there are a host of ambiguities:</p> <ul dir="auto"> <li>Is the range open, half-open, or closed? (I.e. is <code>6</code> included in the above example or not?)</li> <li>Does the range match a single number, or a range object?</li> <li>Range matching is often used for character ranges ('a'...'z') but that won't work in Python since there's no character data type, just strings.</li> <li>Range matching can be a significant performance optimization if you can pre-build a jump table, but that's not generally possible in Python due to the fact that names can be dynamically rebound.</li> </ul> <p dir="auto">Rather than creating a special-case syntax for ranges, it was decided that allowing custom pattern objects (<code>InRange(0, 6)</code>) would be more flexible and less ambiguous; however those ideas have been postponed for the time being (See <a href="#deferred-ideas">deferred ideas</a>).</p> <a name="user-content-use-dispatch-dict-semantics-for-matches"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use dispatch dict semantics for matches</h3><a id="user-content-use-dispatch-dict-semantics-for-matches" class="anchor" aria-label="Permalink: Use dispatch dict semantics for matches" href="#use-dispatch-dict-semantics-for-matches"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Implementations for classic <code>switch</code> statement sometimes use a pre-computed hash table instead of a chained equality comparisons to gain some performance. In the context of <code>match</code> statement this is technically also possible for matches against literal patterns. However, having subtly different semantics for different kinds of patterns would be too surprising for potentially modest performance win.</p> <p dir="auto">We can still experiment with possible performance optimizations in this direction if they will not cause semantic differences.</p> <a name="user-content-use-continue-and-break-in-case-clauses"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use <code>continue</code> and <code>break</code> in case clauses.</h3><a id="user-content-use-continue-and-break-in-case-clauses" class="anchor" aria-label="Permalink: Use continue and break in case clauses." href="#use-continue-and-break-in-case-clauses"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Another rejected proposal was to define new meanings for <code>continue</code> and <code>break</code> inside of <code>match</code>, which would have the following behavior:</p> <ul dir="auto"> <li><code>continue</code> would exit the current case clause and continue matching at the next case clause.</li> <li><code>break</code> would exit the match statement.</li> </ul> <p dir="auto">However, there is a serious drawback to this proposal: if the <code>match</code> statement is nested inside of a loop, the meanings of <code>continue</code> and <code>break</code> are now changed. This may cause unexpected behavior during refactorings; also, an argument can be made that there are other means to get the same behavior (such as using guard conditions), and that in practice it's likely that the existing behavior of <code>continue</code> and <code>break</code> are far more useful.</p> <a name="user-content-and-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">AND (<code>&amp;</code>) patterns</h3><a id="user-content-and--patterns" class="anchor" aria-label="Permalink: AND (&amp;) patterns" href="#and--patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This proposal defines an OR-pattern (<code>|</code>) to match one of several alternates; why not also an AND-pattern (<code>&amp;</code>)? Especially given that some other languages (F# for example) support this.</p> <p dir="auto">However, it's not clear how useful this would be. The semantics for matching dictionaries, objects and sequences already incorporates an implicit 'and': all attributes and elements mentioned must be present for the match to succeed. Guard conditions can also support many of the use cases that a hypothetical 'and' operator would be used for.</p> <p dir="auto">In the end, it was decided that this would make the syntax more complex without adding a significant benefit.</p> <a name="user-content-negative-match-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Negative match patterns</h3><a id="user-content-negative-match-patterns" class="anchor" aria-label="Permalink: Negative match patterns" href="#negative-match-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A negation of a match pattern using the operator <code>!</code> as a prefix would match exactly if the pattern itself does not match. For instance, <code>!(3 | 4)</code> would match anything except <code>3</code> or <code>4</code>.</p> <p dir="auto">This was rejected because there is <a href="https://dl.acm.org/doi/abs/10.1145/2480360.2384582" rel="nofollow">documented evidence</a> that this feature is rarely useful (in languages which support it) or used as double negation <code>!!</code> to control variable scopes and prevent variable bindings (which does not apply to Python). It can also be simulated using guard conditions.</p> <a name="user-content-check-exhaustiveness-at-runtime"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Check exhaustiveness at runtime</h3><a id="user-content-check-exhaustiveness-at-runtime" class="anchor" aria-label="Permalink: Check exhaustiveness at runtime" href="#check-exhaustiveness-at-runtime"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The question is what to do if no case clause has a matching pattern, and there is no default case. An earlier version of the proposal specified that the behavior in this case would be to throw an exception rather than silently falling through.</p> <p dir="auto">The arguments back and forth were many, but in the end the EIBTI (Explicit Is Better Than Implicit) argument won out: it's better to have the programmer explicitly throw an exception if that is the behavior they want.</p> <p dir="auto">For cases such as sealed classes and enums, where the patterns are all known to be members of a discrete set, <a href="#static-checkers-specification">static checkers</a> can warn about missing patterns.</p> <a name="user-content-type-annotations-for-pattern-variables"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Type annotations for pattern variables</h3><a id="user-content-type-annotations-for-pattern-variables" class="anchor" aria-label="Permalink: Type annotations for pattern variables" href="#type-annotations-for-pattern-variables"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The proposal was to combine patterns with type annotations:</p> <pre>match x: case [a: int, b: str]: print(f"An int {a} and a string {b}:) case [a: int, b: int, c: int]: print(f"Three ints", a, b, c) ... </pre> <p dir="auto">This idea has a lot of problems. For one, the colon can only be used inside of brackets or parens, otherwise the syntax becomes ambiguous. And because Python disallows <code>isinstance()</code> checks on generic types, type annotations containing generics will not work as expected.</p> <a name="user-content-allow-rest-in-class-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Allow <code>*rest</code> in class patterns</h3><a id="user-content-allow-rest-in-class-patterns" class="anchor" aria-label="Permalink: Allow *rest in class patterns" href="#allow-rest-in-class-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">It was proposed to allow <code>*rest</code> in a class pattern, giving a variable to be bound to all positional arguments at once (similar to its use in unpacking assignments). It would provide some symmetry with sequence patterns. But it might be confused with a feature to provide the <em>values</em> for all positional arguments at once. And there seems to be no practical need for it, so it was scrapped. (It could easily be added at a later stage if a need arises.)</p> <a name="user-content-disallow-a-in-constant-value-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Disallow <code>_.a</code> in constant value patterns</h3><a id="user-content-disallow-_a-in-constant-value-patterns" class="anchor" aria-label="Permalink: Disallow _.a in constant value patterns" href="#disallow-_a-in-constant-value-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">The first public draft said that the initial name in a constant value pattern must not be <code>_</code> because <code>_</code> has a special meaning in pattern matching, so this would be invalid:</p> <pre>case _.a: ... </pre> <p dir="auto">(However, <code>a._</code> would be legal and load the attribute with name <code>_</code> of the object <code>a</code> as usual.)</p> <p dir="auto">There was some pushback against this on python-dev (some people have a legitimate use for <code>_</code> as an important global variable, esp. in i18n) and the only reason for this prohibition was to prevent some user confusion. But it's not the hill to die on.</p> <a name="user-content-use-some-other-token-as-wildcard"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use some other token as wildcard</h3><a id="user-content-use-some-other-token-as-wildcard" class="anchor" aria-label="Permalink: Use some other token as wildcard" href="#use-some-other-token-as-wildcard"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">It has been proposed to use <code>...</code> (i.e., the ellipsis token) or <code>*</code> (star) as a wildcard. However, both these look as if an arbitrary number of items is omitted:</p> <pre>case [a, ..., z]: ... case [a, *, z]: ... </pre> <p dir="auto">Both look like the would match a sequence of at two or more items, capturing the first and last values.</p> <p dir="auto">In addition, if <code>*</code> were to be used as the wildcard character, we would have to come up with some other way to capture the rest of a sequence, currently spelled like this:</p> <pre>case [first, second, *rest]: ... </pre> <p dir="auto">Using an ellipsis would also be more confusing in documentation and examples, where <code>...</code> is routinely used to indicate something obvious or irrelevant. (Yes, this would also be an argument against the other uses of <code>...</code> in Python, but that water is already under the bridge.)</p> <p dir="auto">Another proposal was to use <code>?</code>. This could be acceptable, although it would require modifying the tokenizer.</p> <p dir="auto">Also, <code>_</code> is already used as a throwaway target in other contexts, and this use is pretty similar. This example is from <code>difflib.py</code> in the stdlib:</p> <pre>for tag, _, _, j1, j2 in group: ... </pre> <p dir="auto">Perhaps the most convincing argument is that <code>_</code> is used as the wildcard in every other language we've looked at supporting pattern matching: C#, Elixir, Erlang, F#, Haskell, Mathematica, OCaml, Ruby, Rust, Scala, and Swift. Now, in general, we should not be concerned too much with what another language does, since Python is clearly different from all these languages. However, if there is such an overwhelming and strong consensus, Python should not go out of its way to do something completely different -- particularly given that <code>_</code> works well in Python and is already in use as a throwaway target.</p> <p dir="auto">Note that <code>_</code> is not assigned to by patterns -- this avoids conflicts with the use of <code>_</code> as a marker for translatable strings and an alias for <code>gettext.gettext</code>, as recommended by the <code>gettext</code> module documentation.</p> <a name="user-content-use-some-other-syntax-instead-of-for-or-patterns"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Use some other syntax instead of <code>|</code> for OR patterns</h3><a id="user-content-use-some-other-syntax-instead-of--for-or-patterns" class="anchor" aria-label="Permalink: Use some other syntax instead of | for OR patterns" href="#use-some-other-syntax-instead-of--for-or-patterns"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A few alternatives to using <code>|</code> to separate the alternatives in OR patterns have been proposed. Instead of:</p> <pre>case 401|403|404: print("Some HTTP error") </pre> <p dir="auto">the following proposals have been fielded:</p> <ul dir="auto"> <li><p dir="auto">Use a comma:</p> <pre>case 401, 403, 404: print("Some HTTP error") </pre> <p dir="auto">This looks too much like a tuple -- we would have to find a different way to spell tuples, and the construct would have to be parenthesized inside the argument list of a class pattern. In general, commas already have many different meanings in Python, we shouldn't add more.</p> </li> <li><p dir="auto">Allow stacked cases:</p> <pre>case 401: case 403: case 404: print("Some HTTP error") </pre> <p dir="auto">This is how this would be done in C, using its fall-through semantics for cases. However, we don't want to mislead people into thinking that <code>match</code>/<code>case</code> uses fall-through semantics (which are a common source of bugs in C). Also, this would be a novel indentation pattern, which might make it harder to support in IDEs and such (it would break the simple rule "add an indentation level after a line ending in a colon"). Finally, this wouldn't support OR patterns nested inside other patterns.</p> </li> <li><p dir="auto">Use <code>case in</code> followed by a comma-separated list:</p> <pre>case in 401, 403, 404: print("Some HTTP error") </pre> <p dir="auto">This wouldn't work for OR patterns nested inside other patterns, like:</p> <pre>case Point(0|1, 0|1): print("A corner of the unit square") </pre> </li> <li><p dir="auto">Use the <code>or</code> keyword:</p> <pre>case 401 or 403 or 404: print("Some HTTP error") </pre> <p dir="auto">This could work, and the readability is not too different from using <code>|</code>. Some users expressed a preference for <code>or</code> because they associate <code>|</code> with bitwise OR. However:</p> <ol dir="auto"> <li><p dir="auto">Many other languages that have pattern matching use <code>|</code> (the list includes Elixir, Erlang, F#, Mathematica, OCaml, Ruby, Rust, and Scala).</p> </li> <li><p dir="auto"><code>|</code> is shorter, which may contribute to the readability of nested patterns like <code>Point(0|1, 0|1)</code>.</p> </li> <li><p dir="auto">Some people mistakenly believe that <code>|</code> has the wrong priority; but since patterns don't support other operators it has the same priority as in expressions.</p> </li> <li><p dir="auto">Python users use <code>or</code> very frequently, and may build an impression that it is strongly associated with Boolean short-circuiting.</p> </li> <li><p dir="auto"><code>|</code> is used between alternatives in regular expressions and in EBNF grammars (like Python's own).</p> </li> <li><p dir="auto"><code>|</code> not just used for bitwise OR -- it's used for set unions, dict merging (<a href="http://www.python.org/dev/peps/pep-0584" rel="nofollow">PEP 584</a>) and is being considered as an alternative to <code>typing.Union</code> (<a href="http://www.python.org/dev/peps/pep-0604" rel="nofollow">PEP 604</a>).</p> </li> <li><p dir="auto"><code>|</code> works better as a visual separator, especially between strings. Compare:</p> <pre>case "spam" or "eggs" or "cheese": </pre> <p dir="auto">to:</p> <pre>case "spam" | "eggs" | "cheese": </pre> </li> </ol> </li> </ul> <a name="user-content-add-an-else-clause"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Add an <code>else</code> clause</h3><a id="user-content-add-an-else-clause" class="anchor" aria-label="Permalink: Add an else clause" href="#add-an-else-clause"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">We decided not to add an <code>else</code> clause for several reasons.</p> <ul dir="auto"> <li>It is redundant, since we already have <code>case _:</code></li> <li>There will forever be confusion about the indentation level of the <code>else:</code> -- should it align with the list of cases or with the <code>match</code> keyword?</li> <li>Completionist arguments like "every other statement has one" are false -- only those statements have an <code>else</code> clause where it adds new functionality.</li> </ul> <a name="user-content-deferred-ideas"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Deferred Ideas</h2><a id="user-content-deferred-ideas" class="anchor" aria-label="Permalink: Deferred Ideas" href="#deferred-ideas"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">There were a number of proposals to extend the matching syntax that we decided to postpone for possible future PEP. These fall into the realm of "cool idea but not essential", and it was felt that it might be better to acquire some real-world data on how the match statement will be used in practice before moving forward with some of these proposals.</p> <p dir="auto">Note that in each case, the idea was judged to be a "two-way door", meaning that there should be no backwards-compatibility issues with adding these features later.</p> <a name="user-content-one-off-syntax-variant"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">One-off syntax variant</h3><a id="user-content-one-off-syntax-variant" class="anchor" aria-label="Permalink: One-off syntax variant" href="#one-off-syntax-variant"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">While inspecting some code-bases that may benefit the most from the proposed syntax, it was found that single clause matches would be used relatively often, mostly for various special-casing. In other languages this is supported in the form of one-off matches. We proposed to support such one-off matches too:</p> <pre>if match value as pattern [and guard]: ... </pre> <p dir="auto">or, alternatively, without the <code>if</code>:</p> <pre>match value as pattern [if guard]: ... </pre> <p dir="auto">as equivalent to the following expansion:</p> <pre>match value: case pattern [if guard]: ... </pre> <p dir="auto">To illustrate how this will benefit readability, consider this (slightly simplified) snippet from real code:</p> <pre>if isinstance(node, CallExpr): if (isinstance(node.callee, NameExpr) and len(node.args) == 1 and isinstance(node.args[0], NameExpr)): call = node.callee.name arg = node.args[0].name ... # Continue special-casing 'call' and 'arg' ... # Follow with common code </pre> <p dir="auto">This can be rewritten in a more straightforward way as:</p> <pre>if match node as CallExpr(callee=NameExpr(name=call), args=[NameExpr(name=arg)]): ... # Continue special-casing 'call' and 'arg' ... # Follow with common code </pre> <p dir="auto">This one-off form would not allow <code>elif match</code> statements, as it was only meant to handle a single pattern case. It was intended to be special case of a <code>match</code> statement, not a special case of an <code>if</code> statement:</p> <pre>if match value_1 as patter_1 [and guard_1]: ... elif match value_2 as pattern_2 [and guard_2]: # Not allowed ... elif match value_3 as pattern_3 [and guard_3]: # Not allowed ... else: # Also not allowed ... </pre> <p dir="auto">This would defeat the purpose of one-off matches as a complement to exhaustive full matches - it's better and clearer to use a full match in this case.</p> <p dir="auto">Similarly, <code>if not match</code> would not be allowed, since <code>match ... as ...</code> is not an expression. Nor do we propose a <code>while match</code> construct present in some languages with pattern matching, since although it may be handy, it will likely be used rarely.</p> <a name="user-content-other-pattern-based-constructions"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Other pattern-based constructions</h3><a id="user-content-other-pattern-based-constructions" class="anchor" aria-label="Permalink: Other pattern-based constructions" href="#other-pattern-based-constructions"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Many other languages supporting pattern-matching use it as a basis for multiple language constructs, including a matching operator, a generalized form of assignment, a filter for loops, a method for synchronizing communication, or specialized if statements. Some of these were mentioned in the discussion of the first draft. Another question asked was why this particular form (joining binding and conditional selection) was chosen while other forms were not.</p> <p dir="auto">Introducing more uses of patterns would be too bold and premature given the experience we have using patterns, and would make this proposal too complicated. The statement as presented provides a form of the feature that is sufficiently general to be useful while being self-contained, and without having a massive impact on the syntax and semantics of the language as a whole.</p> <p dir="auto">After some experience with this feature, the community may have a better feeling for what other uses of pattern matching could be valuable in Python.</p> <a name="user-content-algebraic-matching-of-repeated-names"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Algebraic matching of repeated names</h3><a id="user-content-algebraic-matching-of-repeated-names" class="anchor" aria-label="Permalink: Algebraic matching of repeated names" href="#algebraic-matching-of-repeated-names"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">A technique occasionally seen in functional languages like Erlang and Elixir is to use a match variable multiple times in the same pattern:</p> <pre>match value: case Point(x, x): print("Point is on a diagonal!") </pre> <p dir="auto">The idea here is that the first appearance of <code>x</code> would bind the value to the name, and subsequent occurrences would verify that the incoming value was equal to the value previously bound. If the value was not equal, the match would fail.</p> <p dir="auto">However, there are a number of subtleties involved with mixing load-store semantics for capture patterns. For the moment, we decided to make repeated use of names within the same pattern an error; we can always relax this restriction later without affecting backwards compatibility.</p> <p dir="auto">Note that you <strong>can</strong> use the same name more than once in alternate choices:</p> <pre>match value: case x | [x]: # etc. </pre> <a name="user-content-custom-matching-protocol"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Custom matching protocol</h3><a id="user-content-custom-matching-protocol" class="anchor" aria-label="Permalink: Custom matching protocol" href="#custom-matching-protocol"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">During the initial design discussions for this PEP, there were a lot of ideas thrown around about custom matchers. There were a couple of motivations for this:</p> <ul dir="auto"> <li>Some classes might want to expose a different set of "matchable" names than the actual class properties.</li> <li>Some classes might have properties that are expensive to calculate, and therefore shouldn't be evaluated unless the match pattern actually needed access to them.</li> <li>There were ideas for exotic matchers such as <code>IsInstance()</code>, <code>InRange()</code>, <code>RegexMatchingGroup()</code> and so on.</li> <li>In order for built-in types and standard library classes to be able to support matching in a reasonable and intuitive way, it was believed that these types would need to implement special matching logic.</li> </ul> <p dir="auto">These customized match behaviors would be controlled by a special <code>__match__</code> method on the class name. There were two competing variants:</p> <ul dir="auto"> <li>A 'full-featured' match protocol which would pass in not only the subject to be matched, but detailed information about which attributes the specified pattern was interested in.</li> <li>A simplified match protocol, which only passed in the subject value, and which returned a "proxy object" (which in most cases could be just the subject) containing the matchable attributes.</li> </ul> <p dir="auto">Here's an example of one version of the more complex protocol proposed:</p> <pre>match expr: case BinaryOp(left=Number(value=x), op=op, right=Number(value=y)): ... from types import PatternObject BinaryOp.__match__( (), { "left": PatternObject(Number, (), {"value": ...}, -1, False), "op": ..., "right": PatternObject(Number, (), {"value": ...}, -1, False), }, -1, False, ) </pre> <p dir="auto">One drawback of this protocol is that the arguments to <code>__match__</code> would be expensive to construct, and could not be pre-computed due to the fact that, because of the way names are bound, there are no real constants in Python. It also meant that the <code>__match__</code> method would have to re-implement much of the logic of matching which would otherwise be implemented in C code in the Python VM. As a result, this option would perform poorly compared to an equivalent <code>if</code>-statement.</p> <p dir="auto">The simpler protocol suffered from the fact that although it was more performant, it was much less flexible, and did not allow for many of the creative custom matchers that people were dreaming up.</p> <p dir="auto">Late in the design process, however, it was realized that the need for a custom matching protocol was much less than anticipated. Virtually all the realistic (as opposed to fanciful) uses cases brought up could be handled by the built-in matching behavior, although in a few cases an extra guard condition was required to get the desired effect.</p> <p dir="auto">Moreover, it turned out that none of the standard library classes really needed any special matching support other than an appropriate <code>__match_args__</code> property.</p> <p dir="auto">The decision to postpone this feature came with a realization that this is not a one-way door; that a more flexible and customizable matching protocol can be added later, especially as we gain more experience with real-world use cases and actual user needs.</p> <p dir="auto">The authors of this PEP expect that the <code>match</code> statement will evolve over time as usage patterns and idioms evolve, in a way similar to what other "multi-stage" PEPs have done in the past. When this happens, the extended matching issue can be revisited.</p> <a name="user-content-parameterized-matching-syntax"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Parameterized Matching Syntax</h3><a id="user-content-parameterized-matching-syntax" class="anchor" aria-label="Permalink: Parameterized Matching Syntax" href="#parameterized-matching-syntax"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">(Also known as "Class Instance Matchers".)</p> <p dir="auto">This is another variant of the "custom match classes" idea that would allow diverse kinds of custom matchers mentioned in the previous section -- however, instead of using an extended matching protocol, it would be achieved by introducing an additional pattern type with its own syntax. This pattern type would accept two distinct sets of parameters: one set which consists of the actual parameters passed into the pattern object's constructor, and another set representing the binding variables for the pattern.</p> <p dir="auto">The <code>__match__</code> method of these objects could use the constructor parameter values in deciding what was a valid match.</p> <p dir="auto">This would allow patterns such as <code>InRange&lt;0, 6&gt;(value)</code>, which would match a number in the range 0..6 and assign the matched value to 'value'. Similarly, one could have a pattern which tests for the existence of a named group in a regular expression match result (different meaning of the word 'match').</p> <p dir="auto">Although there is some support for this idea, there was a lot of bikeshedding on the syntax (there are not a lot of attractive options available) and no clear consensus was reached, so it was decided that for now, this feature is not essential to the PEP.</p> <a name="user-content-pattern-utility-library"></a> <div class="markdown-heading" dir="auto"><h3 tabindex="-1" class="heading-element" dir="auto">Pattern Utility Library</h3><a id="user-content-pattern-utility-library" class="anchor" aria-label="Permalink: Pattern Utility Library" href="#pattern-utility-library"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Both of the previous ideas would be accompanied by a new Python standard library module which would contain a rich set of useful matchers. However, it is not really possible to implement such a library without adopting one of the extended pattern proposals given in the previous sections, so this idea is also deferred.</p> <a name="user-content-acknowledgments"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Acknowledgments</h2><a id="user-content-acknowledgments" class="anchor" aria-label="Permalink: Acknowledgments" href="#acknowledgments"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">We are grateful for the help of the following individuals (among many others) for helping out during various phases of the writing of this PEP:</p> <ul dir="auto"> <li>Gregory P. Smith</li> <li>Jim Jewett</li> <li>Mark Shannon</li> <li>Nate Lust</li> <li>Taine Zhao</li> </ul> <a name="user-content-version-history"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Version History</h2><a id="user-content-version-history" class="anchor" aria-label="Permalink: Version History" href="#version-history"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <ol dir="auto"> <li>Initial version</li> <li>Substantial rewrite, including:<ul dir="auto"> <li>Minor clarifications, grammar and typo corrections</li> <li>Rename various concepts</li> <li>Additional discussion of rejected ideas, including:<ul dir="auto"> <li>Why we choose <code>_</code> for wildcard patterns</li> <li>Why we choose <code>|</code> for OR patterns</li> <li>Why we choose not to use special syntax for capture variables</li> <li>Why this pattern matching operation and not others</li> </ul> </li> <li>Clarify exception and side effect semantics</li> <li>Clarify partial binding semantics</li> <li>Drop restriction on use of <code>_</code> in load contexts</li> <li>Drop the default single positional argument being the whole subject except for a handful of built-in types</li> <li>Simplify behavior of <code>__match_args__</code></li> <li>Drop the <code>__match__</code> protocol (moved to <a href="#deferred-ideas">deferred ideas</a>)</li> <li>Drop <code>ImpossibleMatchError</code> exception</li> <li>Drop leading dot for loads (moved to <a href="#deferred-ideas">deferred ideas</a>)</li> <li>Reworked the initial sections (everything before <a href="#syntax-and-semantics">syntax</a>)</li> <li>Added an overview of all the types of patterns before the detailed description</li> <li>Added simplified syntax next to the description of each pattern</li> <li>Separate description of the wildcard from capture patterns</li> <li>Added Daniel F Moisset as sixth co-author</li> </ul> </li> </ol> <a name="user-content-references"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">References</h2><a id="user-content-references" class="anchor" aria-label="Permalink: References" href="#references"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <markdown-accessiblity-table><table frame="void" id="user-content-id5" rules="none"> <tbody valign="top"> <tr><td><a href="#id4">[1]</a></td><td><a href="https://github.com/gvanrossum/patma/blob/master/EXAMPLES.md">https://github.com/gvanrossum/patma/blob/master/EXAMPLES.md</a></td></tr> </tbody> </table></markdown-accessiblity-table> <a name="user-content-appendix-a-full-grammar"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Appendix A -- Full Grammar</h2><a id="user-content-appendix-a----full-grammar" class="anchor" aria-label="Permalink: Appendix A -- Full Grammar" href="#appendix-a----full-grammar"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">Here is the full grammar for <code>match_stmt</code>. This is an additional alternative for <code>compound_stmt</code>. It should be understood that <code>match</code> and <code>case</code> are soft keywords, i.e. they are not reserved words in other grammatical contexts (including at the start of a line if there is no colon where expected). By convention, hard keywords use single quotes while soft keywords use double quotes.</p> <p dir="auto">Other notation used beyond standard EBNF:</p> <ul dir="auto"> <li><code>SEP.RULE+</code> is shorthand for <code>RULE (SEP RULE)*</code></li> <li><code>!RULE</code> is a negative lookahead assertion</li> </ul> <pre lang="text">match_expr: | star_named_expression ',' star_named_expressions? | named_expression match_stmt: "match" match_expr ':' NEWLINE INDENT case_block+ DEDENT case_block: "case" patterns [guard] ':' block guard: 'if' named_expression patterns: value_pattern ',' [values_pattern] | pattern pattern: walrus_pattern | or_pattern walrus_pattern: NAME ':=' or_pattern or_pattern: '|'.closed_pattern+ closed_pattern: | capture_pattern | literal_pattern | constant_pattern | group_pattern | sequence_pattern | mapping_pattern | class_pattern capture_pattern: NAME !('.' | '(' | '=') literal_pattern: | signed_number !('+' | '-') | signed_number '+' NUMBER | signed_number '-' NUMBER | strings | 'None' | 'True' | 'False' constant_pattern: attr !('.' | '(' | '=') group_pattern: '(' patterns ')' sequence_pattern: '[' [values_pattern] ']' | '(' ')' mapping_pattern: '{' items_pattern? '}' class_pattern: | name_or_attr '(' ')' | name_or_attr '(' ','.pattern+ ','? ')' | name_or_attr '(' ','.keyword_pattern+ ','? ')' | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' signed_number: NUMBER | '-' NUMBER attr: name_or_attr '.' NAME name_or_attr: attr | NAME values_pattern: ','.value_pattern+ ','? items_pattern: ','.key_value_pattern+ ','? keyword_pattern: NAME '=' or_pattern value_pattern: '*' capture_pattern | pattern key_value_pattern: | (literal_pattern | constant_pattern) ':' or_pattern | '**' capture_pattern </pre> <a name="user-content-copyright"></a> <div class="markdown-heading" dir="auto"><h2 tabindex="-1" class="heading-element" dir="auto">Copyright</h2><a id="user-content-copyright" class="anchor" aria-label="Permalink: Copyright" href="#copyright"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div> <p dir="auto">This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive.</p> </article></div><button hidden=""></button></section></div></div></div> <!-- --> <!-- --> </div></div></div><div class="Box-sc-g0xbh4-0"></div></div></div></div></div><div id="find-result-marks-container" class="Box-sc-g0xbh4-0 cCoXib"></div><button hidden="" data-testid="" data-hotkey-scope="read-only-cursor-text-area"></button><button hidden=""></button></div> <!-- --> <!-- --> <script type="application/json" id="__PRIMER_DATA_:R0:__">{"resolvedServerColorMode":"day"}</script></div> </react-app> </turbo-frame> </div> </turbo-frame> </main> </div> </div> <footer class="footer pt-8 pb-6 f6 color-fg-muted p-responsive" role="contentinfo" > <h2 class='sr-only'>Footer</h2> <div class="d-flex flex-justify-center flex-items-center flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap"> <div class="d-flex flex-items-center flex-shrink-0 mx-2"> <a aria-label="Homepage" title="GitHub" class="footer-octicon mr-2" href="https://github.com"> <svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M12 1C5.9225 1 1 5.9225 1 12C1 16.8675 4.14875 20.9787 8.52125 22.4362C9.07125 22.5325 9.2775 22.2025 9.2775 21.9137C9.2775 21.6525 9.26375 20.7862 9.26375 19.865C6.5 20.3737 5.785 19.1912 5.565 18.5725C5.44125 18.2562 4.905 17.28 4.4375 17.0187C4.0525 16.8125 3.5025 16.3037 4.42375 16.29C5.29 16.2762 5.90875 17.0875 6.115 17.4175C7.105 19.0812 8.68625 18.6137 9.31875 18.325C9.415 17.61 9.70375 17.1287 10.02 16.8537C7.5725 16.5787 5.015 15.63 5.015 11.4225C5.015 10.2262 5.44125 9.23625 6.1425 8.46625C6.0325 8.19125 5.6475 7.06375 6.2525 5.55125C6.2525 5.55125 7.17375 5.2625 9.2775 6.67875C10.1575 6.43125 11.0925 6.3075 12.0275 6.3075C12.9625 6.3075 13.8975 6.43125 14.7775 6.67875C16.8813 5.24875 17.8025 5.55125 17.8025 5.55125C18.4075 7.06375 18.0225 8.19125 17.9125 8.46625C18.6138 9.23625 19.04 10.2125 19.04 11.4225C19.04 15.6437 16.4688 16.5787 14.0213 16.8537C14.42 17.1975 14.7638 17.8575 14.7638 18.8887C14.7638 20.36 14.75 21.5425 14.75 21.9137C14.75 22.2025 14.9563 22.5462 15.5063 22.4362C19.8513 20.9787 23 16.8537 23 12C23 5.9225 18.0775 1 12 1Z"></path> </svg> </a> <span> &copy; 2025 GitHub,&nbsp;Inc. </span> </div> <nav aria-label="Footer"> <h3 class="sr-only" id="sr-footer-heading">Footer navigation</h3> <ul class="list-style-none d-flex flex-justify-center flex-wrap mb-2 mb-lg-0" aria-labelledby="sr-footer-heading"> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to Terms&quot;,&quot;label&quot;:&quot;text:terms&quot;}" href="https://docs.github.com/site-policy/github-terms/github-terms-of-service" data-view-component="true" class="Link--secondary Link">Terms</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to privacy&quot;,&quot;label&quot;:&quot;text:privacy&quot;}" href="https://docs.github.com/site-policy/privacy-policies/github-privacy-statement" data-view-component="true" class="Link--secondary Link">Privacy</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to security&quot;,&quot;label&quot;:&quot;text:security&quot;}" href="https://github.com/security" data-view-component="true" class="Link--secondary Link">Security</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to status&quot;,&quot;label&quot;:&quot;text:status&quot;}" href="https://www.githubstatus.com/" data-view-component="true" class="Link--secondary Link">Status</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to docs&quot;,&quot;label&quot;:&quot;text:docs&quot;}" href="https://docs.github.com/" data-view-component="true" class="Link--secondary Link">Docs</a> </li> <li class="mx-2"> <a data-analytics-event="{&quot;category&quot;:&quot;Footer&quot;,&quot;action&quot;:&quot;go to contact&quot;,&quot;label&quot;:&quot;text:contact&quot;}" href="https://support.github.com?tags=dotcom-footer" data-view-component="true" class="Link--secondary Link">Contact</a> </li> <li class="mx-2" > <cookie-consent-link> <button type="button" class="Link--secondary underline-on-hover border-0 p-0 color-bg-transparent" data-action="click:cookie-consent-link#showConsentManagement" data-analytics-event="{&quot;location&quot;:&quot;footer&quot;,&quot;action&quot;:&quot;cookies&quot;,&quot;context&quot;:&quot;subfooter&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;cookies_link_subfooter_footer&quot;}" > Manage cookies </button> </cookie-consent-link> </li> <li class="mx-2"> <cookie-consent-link> <button type="button" class="Link--secondary underline-on-hover border-0 p-0 color-bg-transparent" data-action="click:cookie-consent-link#showConsentManagement" data-analytics-event="{&quot;location&quot;:&quot;footer&quot;,&quot;action&quot;:&quot;dont_share_info&quot;,&quot;context&quot;:&quot;subfooter&quot;,&quot;tag&quot;:&quot;link&quot;,&quot;label&quot;:&quot;dont_share_info_link_subfooter_footer&quot;}" > Do not share my personal information </button> </cookie-consent-link> </li> </ul> </nav> </div> </footer> <ghcc-consent id="ghcc" class="position-fixed bottom-0 left-0" style="z-index: 999999" data-initial-cookie-consent-allowed="" data-cookie-consent-required="false"></ghcc-consent> <div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path> </svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button> You can’t perform that action at this time. </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path> </svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details> </template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div> </div> <template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path> </svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path> </svg> </clipboard-copy> </div> </template> <template id="snippet-clipboard-copy-button-unpositioned"> <div class="zeroclipboard-container"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path> </svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path> </svg> </clipboard-copy> </div> </template> </div> <div id="js-global-screen-reader-notice" class="sr-only mt-n1" aria-live="polite" aria-atomic="true" ></div> <div id="js-global-screen-reader-notice-assertive" class="sr-only mt-n1" aria-live="assertive" aria-atomic="true"></div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10