Skip to content

Use Py_VERSION to represent different version #126232

@rruuaanng

Description

@rruuaanng

Feature or enhancement

Proposal:

Actually, there's been an issue that has been bothering me, why not use macros to represent Python version? Using raw hexadecimal numbers seems a bit odd, even though it doesn't affect functionality. I think it might be beneficial to add a macro similar to KERNEL_VERSION to represent a Python version. This would make the code more readable when defining different versions of the API.

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000

replace with

#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= Py_VERSION(3, 7)

So, it's usage is obvious. It's original version can be used

_Py_VERSION(3, 7, 2)
_Py_VERSION(3, 8, 1)
...

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions