Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT: Minor cleanup to F2PY #20884

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 3 commits into from
Mar 21, 2022
Merged

MAINT: Minor cleanup to F2PY #20884

merged 3 commits into from
Mar 21, 2022

Conversation

HaoZeke
Copy link
Member

@HaoZeke HaoZeke commented Jan 24, 2022

This PR:

  • Reuses macro definitions elsewhere in numpy for f2py
  • Clarifies the includes which are generated compared to the ones always present

Draft since after #20881 is in, some of the checks there (BSD, WIN) can be kanged from npy_os.h as well.

@@ -124,6 +124,10 @@
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */

/* Unconditionally included */
#include <Python.h>
#include <numpy/npy_os.h>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically npy_os.h should only be included if long_long or unsigned_long_long or threading is required.

Copy link
Member Author

@HaoZeke HaoZeke Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option which would also provide quite a bit of clean up is to use #include <numpy/npy_common.h> (which defines, among other things, Python.h and npy_os.h) and remove the typedefs used by F2PY for say, complex numbers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In keeping with the original "minor cleanup" spirit of this PR, we will only use npy_os.h here and defer the larger cleanup w.r.t. npy_common.h to #21161.

Copy link
Member

@melissawm melissawm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the most appropriate person to review, but I can confirm all SciPy tests pass with this change.

@HaoZeke HaoZeke marked this pull request as draft January 24, 2022 15:00
@HaoZeke HaoZeke marked this pull request as ready for review March 7, 2022 00:12
@HaoZeke HaoZeke requested a review from melissawm March 7, 2022 00:12
@mattip
Copy link
Member

mattip commented Mar 7, 2022

I am +0 on this. On the one hand, it does seem to standardize the defines to one place. On the other, the defines are only used in ~1 other place anyway, so the cognitive load to know that they are aliases and to find where they are defined is burdensome.

@HaoZeke HaoZeke merged commit 1d9ade8 into numpy:main Mar 21, 2022
@HaoZeke HaoZeke deleted the f2py_npyOS branch March 21, 2022 03:32
cbrt64 added a commit to cbrt64/numpy that referenced this pull request May 25, 2023
Addendum to numpy#20884: fix and deobfuscate Windows OS defines. Specifically,
NPY_OS_WIN64 was never defined, as _WIN32 is defined whenever _WIN64 is.
Also remove NPY_OS_MINGW, since it also never got defined. Note also
that MINGW is not an OS anyway, but a build environment like MSVC.

All changes either preserve functionality or restore original intent.
cbrt64 added a commit to cbrt64/numpy that referenced this pull request May 25, 2023
An addendum to numpy#20884 that fixes and deobfuscates Windows OS defines.
NPY_OS_WIN64 was never defined, as _WIN32 is defined whenever _WIN64 is.
Rename NPY_OS_WIN* constants to be less ambiguous, to avoid future
confusion about their meanings.

Also remove NPY_OS_MINGW, since it too never got defined. Note that
MINGW is not an OS anyway, but a build environment like MSVC.

All changes either preserve functionality or restore original intent.
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.

3 participants