Skip to content

MAINT: Improve const-correctness of shapes and strides#15251

Merged
mattip merged 1 commit intonumpy:masterfrom
eric-wieser:improve-stride-const-correctness
Jan 6, 2020
Merged

MAINT: Improve const-correctness of shapes and strides#15251
mattip merged 1 commit intonumpy:masterfrom
eric-wieser:improve-stride-const-correctness

Conversation

@eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Jan 5, 2020

MAINT: Improve const-correctness of shapes and strides

Marking these arguments as const makes it easier to reason about these functions, and prevent accidental mutation.

The C99 standard (6.2.5/26 "Types") guarantees that ABI compatibility is preserved here.
The only parts of the public API affected are:

  • PyArray_BroadcastToShape
  • PyArray_IntTupleFromIntp
  • PyArray_OverflowMultiplyList

All of which will now accept npy_intp const* dimensions, which is backwards compatible.

Somewhat continues from gh-14484.


Restricted to things of type npy_intp to keep the size of this patch under control.

Left out from this patch is #15252, which would impact downstream compiler warnings.

@eric-wieser eric-wieser force-pushed the improve-stride-const-correctness branch 8 times, most recently from e65f073 to bb22373 Compare January 6, 2020 00:33
@eric-wieser eric-wieser marked this pull request as ready for review January 6, 2020 00:33
Marking these arguments as const makes it easier to reason about these functions, and prevent accidental mutation.

The C99 standard (6.2.5/26 "Types") guarantees that ABI compatibility is preserved here.
@eric-wieser eric-wieser force-pushed the improve-stride-const-correctness branch from bb22373 to c2501e4 Compare January 6, 2020 00:34
@mattip mattip merged commit c28fc48 into numpy:master Jan 6, 2020
@mattip
Copy link
Member

mattip commented Jan 6, 2020

Thanks @eric-wieser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants