Skip to content
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

Merged
merged 3 commits into from
Feb 2, 2019
Merged

bpo-35845: Add order={'C', 'F', 'A'} parameter to memoryview.tobytes(). #11730

merged 3 commits into from
Feb 2, 2019

Conversation

skrah
Copy link
Contributor

@skrah skrah commented Feb 2, 2019

@@ -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)
Copy link
Member

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'?

Copy link
Contributor Author

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.

Copy link
Member

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.

@@ -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'.
Copy link
Member

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.

@@ -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'.
Copy link
Member

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"?).

Copy link
Contributor Author

@skrah skrah Feb 2, 2019

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 skrah merged commit d08ea70 into python:master Feb 2, 2019
@bedevere-bot
Copy link

@skrah: Please replace # with GH- in the commit message next time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants