Skip to content

gh-128813: deprecate cval field of the PyComplexObject struct #137271

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 11 commits into from
Aug 8, 2025

Conversation

skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Jul 31, 2025

@skirpichev skirpichev force-pushed the deprecate-cval/128813 branch from 7b72948 to 40fc415 Compare August 1, 2025 07:49
@skirpichev skirpichev marked this pull request as ready for review August 1, 2025 07:57
@skirpichev skirpichev requested a review from encukou August 1, 2025 07:57
@encukou
Copy link
Member

encukou commented Aug 1, 2025

Per PEP-387, the preferred deprecation period is 5 years (so the removal would be in 3.20). Is there a reason to accelerate that?

@skirpichev
Copy link
Contributor Author

Per PEP-387, the preferred deprecation period is 5 years (so the removal would be in 3.20). Is there a reason to accelerate that?

Hmm, probably not soo much. I would bet, that M$ compiler will not have complex types in 3.17 nor in 3.20. Though, maybe we could keep legacy code with _Py_c_*() functions just for M$ systems and use native language type for the rest.

Quick search on GH give me very few project (two), that use this undocumented field:
https://github.com/search?q=%2F-%3Ecval%2F+language%3AC&type=code&l=C&p=1
This is the only an excuse to use minimal lag in versions between announce and removal, as permitted by PEP 387.

@encukou
Copy link
Member

encukou commented Aug 4, 2025

maybe we could keep legacy code with _Py_c_*() functions just for M$ systems and use native language type for the rest.

I don't think we want to maintain two implementations.

@skirpichev skirpichev requested a review from vstinner August 6, 2025 03:15
@skirpichev
Copy link
Contributor Author

I don't think we want to maintain two implementations.

One of them will be trivial, much like PyFloatObject now. I think that this opportunity could be at least explored. Unless we aren't going into introduction of the imaginary type (which I think is The Right Thing), Annex G double _Complex type - is the future.

I'm fine to delay removal to 3.20. But impact of this deprecation looks to be low and I prefer if it will add as less constraints on us as possible.

CC @vstinner

@skirpichev
Copy link
Contributor Author

BTW, I can do planned reorganization of docs (#137261 (comment)) here. But, probably, it worth a separate pr.

@vstinner
Copy link
Member

vstinner commented Aug 7, 2025

Quick search on GH give me very few project (two), that use this undocumented field

IMO it's fine to only deprecate for 2 releases since it's rare to use the C API to access PyComplex objects. I'm not suprised that a code search only finds 2 projects.

@skirpichev skirpichev requested a review from encukou August 7, 2025 15:20
@encukou
Copy link
Member

encukou commented Aug 7, 2025

One of them will be trivial, much like PyFloatObject now. I think that this opportunity could be at least explored.

If we already need to keep the existing implementation (for MS, and any other compilers without Annex G support), I don't see any benefit in adding a second implementation -- even if it's trivial.

@skirpichev requested a review from @encukou 40 minutes ago

I still see no strong reason to use a shorter-than-default deprecation period.

@skirpichev skirpichev requested a review from AA-Turner as a code owner August 7, 2025 16:30
@skirpichev
Copy link
Contributor Author

Ok, removal deferred to 3.20.

@encukou
Copy link
Member

encukou commented Aug 8, 2025

Thanks! A wording nitpick; but this is ready to go. @vstinner, do you agree?

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner vstinner enabled auto-merge (squash) August 8, 2025 10:30
@vstinner vstinner merged commit 9743d06 into python:main Aug 8, 2025
26 checks passed
@skirpichev skirpichev deleted the deprecate-cval/128813 branch August 8, 2025 10:38
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.

3 participants