Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
No flags argument to memoryview
  • Loading branch information
JelleZijlstra committed Mar 11, 2023
commit f561ddf8871391ca2d161434213787f6463faa02
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ are always available. They are listed here in alphabetical order.


.. _func-memoryview:
.. class:: memoryview(object, *, flags=BufferFlags.FULL_RO)
.. class:: memoryview(object)
:noindex:

Return a "memory view" object created from the given argument. See
Expand Down
14 changes: 1 addition & 13 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3704,7 +3704,7 @@ Memory Views
of an object that supports the :ref:`buffer protocol <bufferobjects>` without
copying.

.. class:: memoryview(object, *, flags=BufferFlags.FULL_RO)
.. class:: memoryview(object)

Create a :class:`memoryview` that references *object*. *object* must
support the buffer protocol. Built-in objects that support the buffer
Expand Down Expand Up @@ -3789,15 +3789,6 @@ copying.
>>> hash(v[::-2]) == hash(b'abcefg'[::-2])
True

The optional ``flags`` can be used to control the :class:`inspect.BufferFlags <buffer flags>`
passed to the underlying buffer. For example::

>>> import inspect
>>> v = memoryview(b"x", flags=inspect.BufferFlags.WRITABLE)
...
BufferError: Object is not writable.
>>> v = memoryview(b"x", flags=inspect.BufferFlags.SIMPLE)

.. versionchanged:: 3.3
One-dimensional memoryviews can now be sliced.
One-dimensional memoryviews with formats 'B', 'b' or 'c' are now :term:`hashable`.
Expand All @@ -3809,9 +3800,6 @@ copying.
.. versionchanged:: 3.5
memoryviews can now be indexed with tuple of integers.

.. versionchanged:: 3.12
Added the ``flags`` argument.

:class:`memoryview` has several methods:

.. method:: __eq__(exporter)
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ are now usable as buffer types.

The new :class:`collections.abc.Buffer` ABC provides a standard
way to represent buffer objects, for example in type annotations.
:class:`memoryview` has a new ``flags`` argument to control the flags
(:class:`inspect.BufferFlags`) passed to the underlying buffer.
The new :class:`inspect.BufferFlags` enum represents the flags that
can be used to customize buffer creation.
(Contributed by Jelle Zijlstra in :gh:`102500`.)

Other Language Changes
Expand Down