Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

memoryview is a Sequence but does not implement the full Sequence API #125420

Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement
@JelleZijlstra

Description

@JelleZijlstra

Bug report

Bug description:

Thememoryview builtin is registered as aSequence, but doesn't implement the full API, because it doesn't inherit fromSequence at runtime and doesn't implement the mixin methods.

>>>importcollections.abc>>>issubclass(memoryview,collections.abc.Sequence)True>>>collections.abc.Sequence.index<functionSequence.indexat0x10148d250>>>>memoryview.indexTraceback (mostrecentcalllast):File"<python-input-4>",line1,in<module>memoryview.indexAttributeError: typeobject'memoryview'hasnoattribute'index'

Among the methods listed for Sequence inthe documentation, memoryview is missing__contains__,__reversed__,index, andcount. 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 whenissubclass() 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.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp