Title: memoryview is a Sequence but does not implement the full Sequence API · Issue #125420 · python/cpython · GitHub
Open Graph Title: memoryview is a Sequence but does not implement the full Sequence API · Issue #125420 · python/cpython
X Title: memoryview is a Sequence but does not implement the full Sequence API · Issue #125420 · python/cpython
Description: Bug report Bug description: The memoryview builtin is registered as a Sequence, but doesn't implement the full API, because it doesn't inherit from Sequence at runtime and doesn't implement the mixin methods. >>> import collections.abc >...
Open Graph Description: Bug report Bug description: The memoryview builtin is registered as a Sequence, but doesn't implement the full API, because it doesn't inherit from Sequence at runtime and doesn't implement the mix...
X Description: Bug report Bug description: The memoryview builtin is registered as a Sequence, but doesn't implement the full API, because it doesn't inherit from Sequence at runtime and doesn't imple...
Opengraph URL: https://github.com/python/cpython/issues/125420
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"memoryview is a Sequence but does not implement the full Sequence API","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nThe `memoryview` builtin is registered as a `Sequence`, but doesn't implement the full API, because it doesn't inherit from `Sequence` at runtime and doesn't implement the mixin methods.\r\n\r\n```python\r\n>>> import collections.abc\r\n>>> issubclass(memoryview, collections.abc.Sequence)\r\nTrue\r\n>>> collections.abc.Sequence.index\r\n\u003cfunction Sequence.index at 0x10148d250>\r\n>>> memoryview.index\r\nTraceback (most recent call last):\r\n File \"\u003cpython-input-4>\", line 1, in \u003cmodule>\r\n memoryview.index\r\nAttributeError: type object 'memoryview' has no attribute 'index'\r\n```\r\n\r\nAmong the methods listed for Sequence in [the documentation](https://docs.python.org/3/library/collections.abc.html), memoryview is missing `__contains__`, `__reversed__`, `index`, and `count`. This is causing problems for typing; in the typeshed stubs we have to either lie one way by claiming that memoryview has methods it doesn't have, or lie another way by claiming it is not a Sequence when `issubclass()` says otherwise at runtime (python/typeshed#12800). To fix this, we should either make memoryview not a Sequence, or add the missing methods. The former has compatibility implications, so I propose to add the methods in 3.14.\r\n\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\n_No response_\r\n\r\n\u003c!-- gh-linked-prs -->\r\n### Linked PRs\r\n* gh-125443\r\n* gh-125446\r\n* (under consideration) gh-125441\r\n* (under consideration) gh-125505\r\n\u003c!-- /gh-linked-prs -->\r\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2024-10-13T23:44:33Z","url":"https://github.com/python/cpython/issues/125420"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:68203b4b-919e-20a7-4a58-0e986479aecc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE82:3F6072:794D:A14A:6B004F18 |
| html-safe-nonce | f3f5987676e871f6b47efb9b60f4d7a1919f4fe813daf800b7b4b310ad28ef72 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTgyOjNGNjA3Mjo3OTREOkExNEE6NkIwMDRGMTgiLCJ2aXNpdG9yX2lkIjoiNjQyNDE0NzY4OTI2MDIwNzg5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f4c915eb5a95f10dea1eda6e8b799c6e03355e8bce4e18afd4848183ffe34e14 |
| hovercard-subject-tag | issue:2584386709 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/125420/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5db320dc5cf7408ae3918f7caf3650e3cd3bd2967310afd5a3c754f23df15e99/python/cpython/issues/125420 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5db320dc5cf7408ae3918f7caf3650e3cd3bd2967310afd5a3c754f23df15e99/python/cpython/issues/125420 |
| og:image:alt | Bug report Bug description: The memoryview builtin is registered as a Sequence, but doesn't implement the full API, because it doesn't inherit from Sequence at runtime and doesn't implement the mix... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width