Skip to content
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

Does PEP 387 apply when correcting deviations from PEP 399? #228

Closed
pganssle opened this issue Jan 17, 2024 · 5 comments
Closed

Does PEP 387 apply when correcting deviations from PEP 399? #228

pganssle opened this issue Jan 17, 2024 · 5 comments

Comments

@pganssle
Copy link
Member

pganssle commented Jan 17, 2024

Modules (like datetime and zoneinfo) that have both pure Python and C-accelerated versions are subject to PEP 399 which says specifically that both the Python and C modules must pass the test suite — though the spirit of the PEP is that the modules should be drop-in replacements for each other with regards to any intentionally-public behavior.

We occasionally find that there is an unintentional discrepancy in behavior between the pure Python and C modules, and we would like to correct it — usually by making the Python version do what the C version does. A recent example of this is when it was discovered that datetime.timezone can be subclassed in the Python module, but not the C module. We decided to remove this capability from the Python module, and the question is: do we need a PEP 387 deprecation period in the pure Python version before we do so, even though we're just bringing it into alignment wth what the C module already does?

@gpshead
Copy link
Member

gpshead commented Jan 17, 2024

My 2 cents personal take: The C implementation is the one that builds of CPython use by default, correct? In that case, I do not think a PEP 387 deprecation period applies to a change of the pure Python implementation to bring its behavior into alignment. The pure Python code that people do not have an easy ability to use is having its behavior aligned with the actual C implementation that is what most of the world uses.

Technical details of this specific case: Lib/datetime.py imports the _datetime C extension, and falls back to Lib/_pydatetime.py if the C extension leads to an ImportError. So both versions of code are shipped, but one should basically never be public in any normal build.

We'll discuss and get back to you with an official answer.

@pganssle
Copy link
Member Author

My 2 cents personal take: The C implementation is the one that builds of CPython use by default, correct?

Yes, this is the case, but the one wrinkle is that PyPy uses the pure Python version unconditionally (since for them, that's the faster version), so there are people out there using the pure Python module without doing any kind of funky thing that would disable the C version. The same goes for zoneinfo and I imagine also heapq.

@gpshead
Copy link
Member

gpshead commented Jan 18, 2024

Yep. Though how much code exclusively uses only that version? I doubt it is a lot, or at least code that is is presumably more likely in private-code land than OSS or anything on PyPI where PyPy is the only runtime someone runs the code on. I think it is fair to say that's up to PyPy to decide themselves when they bring in the 3.13 stdlib.

@mattip
Copy link

mattip commented Jan 18, 2024

FWIW, PyPy's official policy is that undocumented divergence from CPython is a bug to be fixed, and will apply the changes with no deprecation warning for already released versions of Python.

@gpshead
Copy link
Member

gpshead commented Jan 24, 2024

The steering council discussed this today and agree with my response above. no need for a deprecation period.

@gpshead gpshead closed this as completed Jan 24, 2024
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

No branches or pull requests

3 participants