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

Skip to content

Conversation

@scoder
Copy link
Contributor

@scoder scoder commented Mar 11, 2025

Allow ctuples as return type of optimised builtins and use it for divmod() of C integers.

Also make sure that we prefer function signatures with wider numeric types over those with narrower types if there are multiple alternatives. This helps when calling functions with mixed integer types (e.g. arguments int, long should call a function with long, long rather than int, int).

Supersedes and closes #6520

@scoder
Copy link
Contributor Author

scoder commented Mar 19, 2025

I picked independent changes into the master branch to unburden this PR. I think it's ready to merge.

Sadly, we don't use divmod() anywhere in the current benchmarks. And even if it existed, this PR probably wouldn't apply since it deals with C integers, which we rarely infer automatically.

@scoder scoder merged commit 0b866bf into cython:master Mar 20, 2025
72 checks passed
@scoder scoder deleted the cdivmod branch March 20, 2025 05:27
@mroeschke
Copy link

mroeschke commented Apr 9, 2025

Over in pandas, I've discovered that this commit broke some testing we had on our Python 3.13 free threading builds on Windows OS pandas-dev/pandas#61249.

I haven't been able to narrow down why this commit broke some tests, but the common denominator is that arithmetic operations with datetime.timedelta (which we tend to represent as numpy.int64_t in Cython) are not return correct result (values may be under/overflowing).

Edit: Here is an code path where we're calling divmod with integers

https://github.com/pandas-dev/pandas/blob/d1c64045921d7f5b4fe0609b5bc428219c279e5e/pandas/_libs/tslibs/np_datetime.pyx#L672

Edit2: Opened #6786 related to this failure

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.

[ENH] Improve performance of Python division wrapper functions

3 participants