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

MNT: account for CPython 314 changes #760

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions msgspec/_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define PY311_PLUS (PY_VERSION_HEX >= 0x030b0000)
#define PY312_PLUS (PY_VERSION_HEX >= 0x030c0000)
#define PY313_PLUS (PY_VERSION_HEX >= 0x030d0000)
#define PY314_PLUS (PY_VERSION_HEX >= 0x030e0000)

/* Hint to the compiler not to store `x` in a register since it is likely to
* change. Results in much higher performance on GCC, with smaller benefits on
Expand Down Expand Up @@ -71,6 +72,12 @@ ms_popcount(uint64_t i) { \
#define MS_UNICODE_EQ(a, b) _PyUnicode_EQ(a, b)
#endif

#if PY314_PLUS
#define MS_IMMORTAL_INITIAL_REFCNT _Py_IMMORTAL_INITIAL_REFCNT
#else
#define MS_IMMORTAL_INITIAL_REFCNT _Py_IMMORTAL_REFCNT
#endif

#define DIV_ROUND_CLOSEST(n, d) ((((n) < 0) == ((d) < 0)) ? (((n) + (d)/2)/(d)) : (((n) - (d)/2)/(d)))

/* These macros are used to manually unroll some loops */
Expand Down Expand Up @@ -2155,7 +2162,7 @@ PyTypeObject NoDefault_Type = {
#if PY312_PLUS
PyObject _NoDefault_Object = {
_PyObject_EXTRA_INIT
{ _Py_IMMORTAL_REFCNT },
{ MS_IMMORTAL_INITIAL_REFCNT },
&NoDefault_Type
};
#else
Expand Down Expand Up @@ -2259,7 +2266,7 @@ PyTypeObject Unset_Type = {
#if PY312_PLUS
PyObject _Unset_Object = {
_PyObject_EXTRA_INIT
{ _Py_IMMORTAL_REFCNT },
{ MS_IMMORTAL_INITIAL_REFCNT },
&Unset_Type
};
#else
Expand Down
Loading