Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PEP 670: Convert datetime.h macros to functions #96822

Closed
vstinner opened this issue Sep 14, 2022 · 2 comments
Closed

PEP 670: Convert datetime.h macros to functions #96822

vstinner opened this issue Sep 14, 2022 · 2 comments
Labels
type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

The datetime.h header file provides two kinds of C API:

  • Function pointers exposed via PyDateTime_CAPI structure and a PyCapsule object
  • Macros like PyTime_Check() and PyTime_FromTime(): their implementation uses the function pointers

I propose converting these macros to regular functions to avoid leaking implementation details in the ABI. It moves this API closer to the limited C API and the stable ABI (PEP 384).

I propose a first PR to convert macros like PyTime_FromTime() to regular functions.

Later, I also plan to work on a separated PR to convert "GET" macros, like PyDateTime_GET_YEAR(), to static inline functions or regular functions.

Note: currently, datetime.h is not included by Python.h and is excluded from the limited C API.

@vstinner vstinner added the type-feature A feature request or enhancement label Sep 14, 2022
@vstinner
Copy link
Member Author

I propose a first PR to convert macros like PyTime_FromTime() to regular functions.

Oh, wait. The _datetime extension is built as a shared library, my idea doesn't work... When I built again my local branches, _zoneinfo and _testcapi fail to build.

@vstinner
Copy link
Member Author

vstinner commented Nov 3, 2022

I close the issue. I will try to first get PEP 674 accepted ;-) This change is more related to PEP 674 than PEP 670.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant