8000 ENH: Do not emit compiler warning if forcing old API by mattip · Pull Request #12286 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Do not emit compiler warning if forcing old API #12286

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

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

mattip
Copy link
Member
@mattip mattip commented Oct 29, 2018

If a user does not define NPY_NO_DEPRECATED_API, we emit a warning encouraging them to choose an api version. If they choose NPY_1_7_API_VERSION or earlier, we include a special header with many old API interfaces. This is still needed for correct operation with cython, see cython/cython#2640 for a possible solution. Until we can truly deprecate the old APIs (or decide to revert the deprecation), choosing the old API should not emit a compiler warning.

@charris
Copy link
Member
charris commented Oct 29, 2018

I'm trying to recall who needs this at this time.

@mattip
Copy link
Member Author
mattip commented Oct 29, 2018

Anyone who want to avoid the warning needs to define NPY_NO_DEPRECATED API. In order to nicely use Cython, they need to use the 1.7 API. Otherwise cython will not be able to convert slow python attribute lookup (array.ndim in python) into fast c-struct field access (array->nd in C) because starting from 1.8 we hid the fields from cython (PyArray_NDIM(array)), which cython cannot grok yet.

@mattip
Copy link
Member Author
mattip commented Oct 29, 2018

I need it for PR #12284 for mtrand.pyx to compile without the warning

@rgommers
Copy link
Member

+1 for hiding this warning. Whoever hasn't upgraded yet after 10 releases won't do so anymore because of this warning, so it's just a lot of noise now.

@rgommers
Copy link
Member

Ah tested and still seeing it - I thought the intent was never to show this warning anymore. I'd be fine with that.

@mattip
Copy link
Member Author
mattip commented Oct 31, 2018

Any more comments? Can I merge?

@eric-wieser
Copy link
Member

It might be nice to paraphrase @rgommers comment beside the #if, to justify why the warning is not emitted if the user explicitly requested the deprecated API.

While it's true that ignoring it for 10 releases probably means downstream users will continue to do so, I'm not sure I see the argument for saving those users from noise. Can you elaborate on why this warning needs to go away for cython compatibility?

Until we can truly deprecate the old APIs

I assume you mean remove completely

@mattip
Copy link
Member Author
mattip commented Oct 31, 2018

justify why the warning is not emitted if the user explicitly requested the deprecated API

This PR will change the current behaviour to not emit a warning if the user explicitly requests an API version.

@mattip mattip added this to the 1.16.0 release milestone Nov 4, 2018
@mattip
Copy link
Member Author
mattip commented Nov 14, 2018

Added a comment to the header

@charris
Copy link
Member
charris commented Nov 16, 2018

Don't see a problem with this, especially if it helps Cython in the short term. I guess the other option is to disable the warning entirely, and we can maybe do that at some point. Another option is to make it explicit,

#define NPY_DEPRECATED_API

@charris charris merged commit f332aae into numpy:master Nov 20, 2018
@charris
Copy link
Member
charris commented Nov 20, 2018 8C3B

Thanks Matti.

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.

4 participants
0