question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change to non-deprecated NumPy C API

See original GitHub issue

This is an issue to summarize the current status of NumPy C API support and what can/should be done to update Cython. (cc @mattip, this is what I was talking about yesterday - could be a useful thing to work on).

Currently Cython uses a NumPy API that has been deprecated since NumPy 1.6.0 in 2013.

The Cython docs say here: “For the time being, it is just a warning that you can ignore.”.

It is about time to update this, it will save users a lot of confusion and shorten the build logs of many projects by hundreds of lines.

@nouiz wrote a summary of how to support both old (<1.6.0) and new API:

I would suggest that it’s either no longer needed to support the old <1.6 API, or make that opt-in rather than the default (to avoid all the build warnings while remaining compatible with very old NumPy versions). Would be good to get the opinion of the Cython team on this before starting work on this.

Here is an example of changing to the new API and avoiding the build warnings for scipy.optimize: https://github.com/scipy/scipy/pull/4351/files. Linking because the use of numpy_nodepr_api there (the defines and passing them to distutils) may be useful to other projects; it’s a bit nontrivial to get right.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:27 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
mattipcommented, Mar 22, 2020

I think we can close this. Things like this PR in scipy can be finished once cython releases 3.0.

0reactions
scodercommented, Mar 22, 2020

Is this done now, or is there still anything missing?

Cython doesn’t currently set the NumPy deprecated API marker itself, so that’s left to users. Is that ok, or can/should we do anything else to help them?

Read more comments on GitHub >

github_iconTop Results From Across the Web

C API Deprecations — NumPy v1.23 Manual
One way to do deprecations is to flag them in the documentation and release notes, then remove or change the deprecated features in...
Read more >
How to modernize code that uses deprecated NumPy C API?
The code is up to date. There is no need for modernization. The code line #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION.
Read more >
Unicode Objects and Codecs — Python 3.11.1 documentation
“canonical” Unicode objects are all objects created by a non-deprecated Unicode API. They use the most efficient representation allowed by the ...
Read more >
The Python/C API
Traditionally, the C API of Python will change with every release. ... objects are all objects created by a non-deprecated unicode API.
Read more >
C API Deprecations — NumPy v1.9 Manual
One way to do deprecations is to flag them in the documentation and release notes, then remove or change the deprecated features in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found