Skip to content

gh-131331: rename not field to invert for C++ extension modules #131334

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
Mar 20, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ typedef struct _jit_opt_tuple {

typedef struct {
uint8_t tag;
bool not;
bool invert;
uint16_t value;
} JitOptTruthiness;

Expand Down
16 changes: 8 additions & 8 deletions Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ _Py_uop_sym_is_const(JitOptContext *ctx, JitOptSymbol *sym)
if (truthiness < 0) {
return false;
}
make_const(sym, (truthiness ^ sym->truthiness.not) ? Py_True : Py_False);
make_const(sym, (truthiness ^ sym->truthiness.invert) ? Py_True : Py_False);
return true;
}
return false;
Expand All @@ -138,7 +138,7 @@ _Py_uop_sym_get_const(JitOptContext *ctx, JitOptSymbol *sym)
if (truthiness < 0) {
return NULL;
}
PyObject *res = (truthiness ^ sym->truthiness.not) ? Py_True : Py_False;
PyObject *res = (truthiness ^ sym->truthiness.invert) ? Py_True : Py_False;
make_const(sym, res);
return res;
}
Expand Down Expand Up @@ -289,7 +289,7 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
}
JitOptSymbol *value = allocation_base(ctx) + sym->truthiness.value;
PyTypeObject *type = _Py_uop_sym_get_type(value);
if (const_val == (sym->truthiness.not ? Py_False : Py_True)) {
if (const_val == (sym->truthiness.invert ? Py_False : Py_True)) {
// value is truthy. This is only useful for bool:
if (type == &PyBool_Type) {
_Py_uop_sym_set_const(ctx, value, Py_True);
Expand Down Expand Up @@ -496,7 +496,7 @@ _Py_uop_sym_truthiness(JitOptContext *ctx, JitOptSymbol *sym)
if (truthiness < 0) {
return truthiness;
}
truthiness ^= sym->truthiness.not;
truthiness ^= sym->truthiness.invert;
make_const(sym, truthiness ? Py_True : Py_False);
return truthiness;
}
Expand Down Expand Up @@ -590,8 +590,8 @@ JitOptSymbol *
_Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy)
{
// It's clearer to invert this in the signature:
bool not = !truthy;
if (value->tag == JIT_SYM_TRUTHINESS_TAG && value->truthiness.not == not) {
bool invert = !truthy;
if (value->tag == JIT_SYM_TRUTHINESS_TAG && value->truthiness.invert == invert) {
return value;
}
JitOptSymbol *res = sym_new(ctx);
Expand All @@ -601,11 +601,11 @@ _Py_uop_sym_new_truthiness(JitOptContext *ctx, JitOptSymbol *value, bool truthy)
int truthiness = _Py_uop_sym_truthiness(ctx, value);
if (truthiness < 0) {
res->tag = JIT_SYM_TRUTHINESS_TAG;
res->truthiness.not = not;
res->truthiness.invert = invert;
res->truthiness.value = (uint16_t)(value - allocation_base(ctx));
}
else {
make_const(res, (truthiness ^ not) ? Py_True : Py_False);
make_const(res, (truthiness ^ invert) ? Py_True : Py_False);
}
return res;
}
Expand Down
Loading