Transition `PyArray_PythonPyIntFromInt` to modern behavior
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
PyArray_PythonPyIntFromInt existed to not change behavior of existing code that used the "i" format in Python.
But along the way, Python fixed their things, the conversion now uses __index__ as it should and rejects all non-integers (not just floats explictly).
We missed that and while we used to be ahead of the curve we are now behind here. So what we should do is:
- Try the
__index__style conversion. (this is a tiny bug fix as well) - If that fails, try current code with a warning.
It would be nice to audit if there are remaining "i" uses that matters, because if there aren't we can be clearer about when the warning was introduced (i.e. we won't use it for more functions).
Additionally, it may be nice to do a check whether all integers are used in places where NumPy may just want to directly transition to our integer conversion helpers. These differ in that NumPy sometimes rejects booleans.
(This doesn't matter much either way, the bool rejecting matters mostly in places that are slightly indexing related.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate PyArray_PythonPyIntFromInt and trace its current conversion path and warning behavior. Audit remaining "i" uses and related integer conversion helpers, then verify that __index__ is attempted first, the fallback warns, and relevant conversion behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100