-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-35845: Add order={'C', 'F', 'A'} parameter to memoryview.tobytes(). #11730
Conversation
@@ -3600,7 +3600,7 @@ copying. | |||
Previous versions compared the raw memory disregarding the item format | |||
and the logical array structure. | |||
|
|||
.. method:: tobytes() | |||
.. method:: tobytes(order=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you write it as order='C'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that common practice? I'd assume that order='C'
means that a function raises a TypeError
with a None
argument. I supported None
because NumPy does, too.
OTOH NumPy also documents the function with order='C'
, but I assumed that was an oversight or a historical quirk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realize that passing None
explicitly was supported.
Doc/library/stdtypes.rst
Outdated
@@ -3616,6 +3616,10 @@ copying. | |||
supports all format strings, including those that are not in | |||
:mod:`struct` module syntax. | |||
|
|||
*Order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data | |||
of the original array is converted to C or Fortran order. 'A' returns | |||
the data in the existing order. The default order is 'C'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a versionchanged
tag for the new argument.
Doc/library/stdtypes.rst
Outdated
@@ -3616,6 +3616,10 @@ copying. | |||
supports all format strings, including those that are not in | |||
:mod:`struct` module syntax. | |||
|
|||
*Order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data | |||
of the original array is converted to C or Fortran order. 'A' returns | |||
the data in the existing order. The default order is 'C'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than "existing order", I would say "physical order" (or more precisely, "'F' if the buffer is Fortran-contiguous, 'C' otherwise"?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's use the more precise version. 'A'
does convert non-contiguous buffers to 'C'
, so it should be mentioned.
@skrah: Please replace |
https://bugs.python.org/issue35845