Skip to content

ENH: Rationalize f2py callback check to just require callable#31599

Open
da-woods wants to merge 3 commits into
numpy:mainfrom
da-woods:rationalize-function
Open

ENH: Rationalize f2py callback check to just require callable#31599
da-woods wants to merge 3 commits into
numpy:mainfrom
da-woods:rationalize-function

Conversation

@da-woods

Copy link
Copy Markdown
Contributor

PR summary

... rather than specific types of callable. This means that we can eliminate the PyFortranType_Check1 (which is hard to do in the Limited API) because it's just caught by callable.

Also:

  • Add some extra tests (which were already working before the changes, but good to test anyway)
  • Get rid of some dead py2 code-paths (im_func)

AI Disclosure

No AI usage.

... rather than specific types of callable. This means that we
can eliminate the PyFortranType_Check1 (which is hard to do in
the Limited API) because it's just caught by callable.

Also get rid of some dead py2 code-paths.
Comment thread numpy/f2py/cfuncs.py
}
Py_XDECREF(tmp);
}
else if (PyFortran_Check(fun) || PyFortran_Check1(fun)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Really the motivation is just getting rid of this line to avoid adapting PyFortran_Check1 for the Limited API.

It would definitely be possible to adapt the check though for a less intrusive fix. But the cleanup felt like an improvement.

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.

1 participant