René's URL Explorer Experiment


Title: Feature Request: Type hint for Fixed Length Homogeneous Sequences · Issue #786 · python/typing · GitHub

Open Graph Title: Feature Request: Type hint for Fixed Length Homogeneous Sequences · Issue #786 · python/typing

X Title: Feature Request: Type hint for Fixed Length Homogeneous Sequences · Issue #786 · python/typing

Description: Feature A concise way to hint that a sequence of homogenous types is a set length. i.e The items in the sequence are all of the same type, the sequence is iterable, and cannot grow larger or smaller. Pitch Currently, the recommended way ...

Open Graph Description: Feature A concise way to hint that a sequence of homogenous types is a set length. i.e The items in the sequence are all of the same type, the sequence is iterable, and cannot grow larger or smalle...

X Description: Feature A concise way to hint that a sequence of homogenous types is a set length. i.e The items in the sequence are all of the same type, the sequence is iterable, and cannot grow larger or smalle...

Opengraph URL: https://github.com/python/typing/issues/786

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature Request: Type hint for Fixed Length Homogeneous Sequences","articleBody":"**Feature**\r\n\r\nA concise way to hint that a sequence of homogenous types is a set length. i.e The items in the sequence are all of the same type, the sequence is iterable, and cannot grow larger or smaller.\r\n\r\n**Pitch**\r\n\r\nCurrently, the recommended way to add type hints to fixed-length sequences is to use Tuples [\u003csup>1\u003c/sup>](https://stackoverflow.com/questions/44833822/specify-length-of-sequence-or-list-with-python-typing-module). i.e\r\n```python\r\ndef foo(ten_floats: Tuple[float,float,float,float,float,float,float,float,float,float]):\r\n    ...\r\n````\r\nFor longer lists, this repetition is tedious and prone to error.\r\nIt would be nice to have a shorthand for defining homogeneous tuples. e.g\r\n```python\r\ndef foo(ten_floats: HomogeneousTuple[float, 10]):\r\n    ...\r\n````\r\n\r\nAlthough the name `Tuple` does not signal intent very well. The real thing that we are trying to signal is that this is a sequence of floats of length 10. It does not necessarily have to be a Tuple, it just has to be iterable, and have 10 items, that cannot grow larger or smaller. If I wanted to pass the function a List, this should also pass static type checkers, as long as it has 10 floats.\r\n\r\n\r\n**Possible Implementation**\r\n\r\nI am not a core python developer, I have never even looked at the implementation of the typing module, and I'm not even that good of a python developer, so please forgive me if this is nonsense.\r\n\r\nIn Python 3.10 or newer \u003csup>[2]\u003c/sup> we will be able to use the unpack operator in subscript. So we might be able to do something like:\r\n\r\n```python\r\n_t=[float]*10\r\ndef foo(ten_floats: Tuple[*_t]):\r\n    ...\r\n```\r\n\r\nUsing TypeVars, we could generalize this function to accept 10 of any type (as long as they are all the same type)\r\n\r\n```python\r\nT=TypeVar('T')\r\nTenTypeVars=[T]*10\r\ndef foo(ten_homogeneous_items: Tuple[*TenTypeVars]):\r\n    ...\r\n```\r\n\r\n\r\nFollowing this logic, perhaps a generic type hint for Fixed Length Homogeneous Sequences could be implemented with\r\n\r\n```python\r\nclass FixedLengthHomogeneousSequence(Generic[T, N], Tuple[*[T]*N]):\r\n    ...\r\n```\r\n\r\n`FixedLengthHomogeneousSequence` is a bit wordy. So perhaps `FixedList` would be a better name.\r\n\r\n[2] (I think this is true). Pylance gave me an error saying this was the case. I think it's related to https://www.python.org/dev/peps/pep-0622/","author":{"url":"https://github.com/craigh92","@type":"Person","name":"craigh92"},"datePublished":"2021-02-11T13:38:53Z","url":"https://github.com/python/typing/issues/786"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:986c6bed-3d99-025b-f953-49ef67229e34
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9204:37BEAD:1EBBFBD:29C5088:6B001666
html-safe-nonce0a6840d9dcfcc5a69a3a3edd775240f3cfd1d622c4a0a41aa8fef274f624c66a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjA0OjM3QkVBRDoxRUJCRkJEOjI5QzUwODg6NkIwMDE2NjYiLCJ2aXNpdG9yX2lkIjoiNzYzMjQwMDI2OTY5ODkzMDI3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5c609494b8d4bcd5306bc8fe9c126538f42356a175951c9bc14b1a4740bcad20
hovercard-subject-tagissue:806398663
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typing/786/issue_layout
twitter:imagehttps://opengraph.githubassets.com/36ee0860c8281dd4c2114c51e8bb7d135e1cd357ce3b29f732572b374b131165/python/typing/issues/786
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/36ee0860c8281dd4c2114c51e8bb7d135e1cd357ce3b29f732572b374b131165/python/typing/issues/786
og:image:altFeature A concise way to hint that a sequence of homogenous types is a set length. i.e The items in the sequence are all of the same type, the sequence is iterable, and cannot grow larger or smalle...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecraigh92
hostnamegithub.com
expected-hostnamegithub.com
Nonea2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4
turbo-cache-controlno-preview
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release70121d4e855ee0bb7b75cf15d061d91f8863c0f8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typing/issues/786#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F786
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fissues%2F786
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Ftyping
Reloadhttps://github.com/python/typing/issues/786
Reloadhttps://github.com/python/typing/issues/786
Reloadhttps://github.com/python/typing/issues/786
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
https://github.com/python/typing
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/786
New issuehttps://github.com/login?return_to=https://github.com/python/typing/issues/786
Feature Request: Type hint for Fixed Length Homogeneous Sequenceshttps://github.com/python/typing/issues/786#top
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
https://github.com/craigh92
craigh92https://github.com/craigh92
on Feb 11, 2021https://github.com/python/typing/issues/786#issue-806398663
1https://stackoverflow.com/questions/44833822/specify-length-of-sequence-or-list-with-python-typing-module
https://www.python.org/dev/peps/pep-0622/https://www.python.org/dev/peps/pep-0622/
https://github.com/jp-larose
jp-larosehttps://github.com/jp-larose
on May 5, 2021https://github.com/python/typing/issues/786#issuecomment-832919751
srittauhttps://github.com/srittau
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
on Nov 4, 2021https://github.com/python/typing/issues/786#event-5568210698
https://github.com/garrison
garrisonhttps://github.com/garrison
on Jan 24, 2023https://github.com/python/typing/issues/786#issuecomment-1401321576
https://github.com/Ricyteach
Ricyteachhttps://github.com/Ricyteach
on Jul 5, 2023https://github.com/python/typing/issues/786#issuecomment-1622459609
https://github.com/jp-larose
jp-larosehttps://github.com/jp-larose
on Jul 11, 2023https://github.com/python/typing/issues/786#issuecomment-1630013217
https://github.com/jacktose
jacktosehttps://github.com/jacktose
on Jan 10, 2024https://github.com/python/typing/issues/786#issuecomment-1885350772
https://github.com/lou1306
lou1306https://github.com/lou1306
on Aug 23, 2024https://github.com/python/typing/issues/786#issuecomment-2306918493
https://github.com/Shaked-Q
Shaked-Qhttps://github.com/Shaked-Q
on Aug 25, 2024https://github.com/python/typing/issues/786#issuecomment-2308880058
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typing/issues/786
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typing/issues/786
topic: featureDiscussions about new features for Python's type annotationshttps://github.com/python/typing/issues?q=state%3Aopen%20label%3A%22topic%3A%20feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.