Skip to content

gh-135379: Move PyLong_CheckCompact to private header #135707

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 2 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move PyLong_CheckCompact to private header
  • Loading branch information
Fidget-Spinner committed Jun 19, 2025
commit 9930928e950e048b2408f55fb60f301c6dd1e7c0
6 changes: 0 additions & 6 deletions Include/cpython/longintrepr.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ _PyLong_IsCompact(const PyLongObject* op) {
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
}

static inline int
PyLong_CheckCompact(PyObject *op)
{
return PyLong_CheckExact(op) && _PyLong_IsCompact((const PyLongObject *)op);
}

#define PyUnstable_Long_IsCompact _PyLong_IsCompact

static inline Py_ssize_t
Expand Down
6 changes: 6 additions & 0 deletions Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ _PyLong_FlipSign(PyLongObject *op) {
#define _PyLong_FALSE_TAG TAG_FROM_SIGN_AND_SIZE(0, 0)
#define _PyLong_TRUE_TAG TAG_FROM_SIGN_AND_SIZE(1, 1)

static inline int
_PyLong_CheckCompact(PyObject *op)
{
return PyLong_CheckExact(op) && _PyLong_IsCompact((const PyLongObject *)op);
}

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,12 @@ dummy_func(

op(_GUARD_NOS_INT, (left, unused -- left, unused)) {
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
EXIT_IF(!PyLong_CheckCompact(left_o));
EXIT_IF(!_PyLong_CheckCompact(left_o));
}

op(_GUARD_TOS_INT, (value -- value)) {
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
EXIT_IF(!PyLong_CheckCompact(value_o));
EXIT_IF(!_PyLong_CheckCompact(value_o));
}

op(_GUARD_NOS_OVERFLOWED, (left, unused -- left, unused)) {
Expand Down
4 changes: 2 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptRef ref, PyObject *const_val)
make_const(sym, const_val);
return;
case JIT_SYM_COMPACT_INT:
if (PyLong_CheckCompact(const_val)) {
if (_PyLong_CheckCompact(const_val)) {
make_const(sym, const_val);
}
else {
Expand Down Expand Up @@ -679,7 +679,7 @@ _Py_uop_sym_is_compact_int(JitOptRef ref)
{
JitOptSymbol *sym = PyJitRef_Unwrap(ref);
if (sym->tag == JIT_SYM_KNOWN_VALUE_TAG) {
return (bool)PyLong_CheckCompact(sym->value.value);
return (bool)_PyLong_CheckCompact(sym->value.value);
}
return sym->tag == JIT_SYM_COMPACT_INT;
}
Expand Down Expand Up @@ -716,7 +716,7 @@ _Py_uop_sym_set_compact_int(JitOptContext *ctx, JitOptRef ref)
}
return;
case JIT_SYM_KNOWN_VALUE_TAG:
if (!PyLong_CheckCompact(sym->value.value)) {
if (!_PyLong_CheckCompact(sym->value.value)) {
Py_CLEAR(sym->value.value);
sym_set_bottom(ctx, sym);
}
Expand Down
2 changes: 1 addition & 1 deletion Tools/cases_generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def has_error_without_pop(op: parser.CodeDef) -> bool:
"PyStackRef_IsValid",
"PyStackRef_Wrap",
"PyStackRef_Unwrap",
"PyLong_CheckCompact",
"_PyLong_CheckCompact",
)


Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy