10000 bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects by ericsnowcurrently · Pull Request #31366 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects #31366

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
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
Prev Previous commit
Next Next commit
Use _Py_ID() in codeobject.c.
  • Loading branch information
ericsnowcurrently committed Feb 16, 2022
commit 5f2746b3993166efa2b07065bded93dcb21931d1
18 changes: 6 additions & 12 deletions Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,11 @@ PyCode_New(int argcount, int kwonlyargcount,
PyCodeObject *
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
{
PyObject *emptystring = NULL;
PyObject *nulltuple = NULL;
PyObject *filename_ob = NULL;
PyObject *funcname_ob = NULL;
PyCodeObject *result = NULL;

emptystring = PyBytes_FromString("");
if (emptystring == NULL) {
goto failed;
}
nulltuple = PyTuple_New(0);
if (nulltuple == NULL) {
goto failed;
Expand All @@ -580,21 +575,20 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
.filename = filename_ob,
.name = funcname_ob,
.qualname = funcname_ob,
.code = emptystring,
.code = &_Py_STR(empty),
.firstlineno = firstlineno,
.linetable = emptystring,
.endlinetable = emptystring,
.columntable = emptystring,
.linetable = &_Py_STR(empty),
.endlinetable = &_Py_STR(empty),
.columntable = &_Py_STR(empty),
.consts = nulltuple,
.names = nulltuple,
.localsplusnames = nulltuple,
.localspluskinds = emptystring,
.exceptiontable = emptystring,
.localspluskinds = &_Py_STR(empty),
.exceptiontable = &_Py_STR(empty),
};
result = _PyCode_New(&con);

failed:
Py_XDECREF(emptystring);
Py_XDECREF(nulltuple);
Py_XDECREF(funcname_ob);
Py_XDECREF(filename_ob);
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ Objects/sliceobject.c - _Py_EllipsisObject -
# cached - initialized once

# manually cached PyUnicodeObject
Objects/codeobject.c PyCode_NewEmpty emptystring -
Objects/exceptions.c _check_for_legacy_statements print_prefix -
Objects/exceptions.c _check_for_legacy_statements exec_prefix -
Objects/funcobject.c PyFunction_NewWithQualName __name__ -
Expand Down
0