GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46430: Intern strings in deep-frozen modules by kumaraditya303 · Pull Request #30683 · python/cpython

bpo-46430: Intern strings in deep-frozen modules #30683

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.

Sign up for GitHub

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
gvanrossum merged 6 commits into python:main from kumaraditya303:intern
Feb 9, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

bpo-46430: Intern strings in deep-frozen modules #30683

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
6 commits
Select commit Hold shift + click to select a range
5ead58b
intern strings
kumaraditya303 Feb 6, 2022
b2d3eb2
📜🤖 Added by blurb_it.
blurb-it[bot] Jan 19, 2022
ed8f718
rework
kumaraditya303 Feb 6, 2022
a5d9fab
rework
kumaraditya303 Feb 6, 2022
f6d207a
fix warning
kumaraditya303 Feb 6, 2022
08dc8e5
space
kumaraditya303 Feb 6, 2022
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

2 changes: 2 additions & 0 deletions 2 Include/internal/pycore_code.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ void _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,

/* Deallocator function for static codeobjects used in deepfreeze.py */
void _PyStaticCode_Dealloc(PyCodeObject *co);
/* Function to intern strings of codeobjects */
void _PyStaticCode_InternStrings(PyCodeObject *co);

#ifdef Py_STATS

Expand Down
1 change: 1 addition & 0 deletions 1 Misc/NEWS.d/next/Build/2022-01-19-11-08-32.bpo-46430.k403m_.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Intern strings in deep-frozen modules. Patch by Kumar Aditya.
12 changes: 12 additions & 0 deletions 12 Objects/codeobject.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1924,3 +1924,15 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
co->co_weakreflist = NULL;
}
}

void
_PyStaticCode_InternStrings(PyCodeObject *co)
{
int res = intern_strings(co->co_names);
assert(res == 0);
res = intern_string_constants(co->co_consts, NULL);
assert(res == 0);
res = intern_strings(co->co_localsplusnames);
assert(res == 0);
(void)res;
}
Comment thread
kumaraditya303 marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

1 change: 1 addition & 0 deletions 1 Tools/scripts/deepfreeze.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def generate_code(self, name: str, code: types.CodeType) -> str:
self.write(f".co_cellvars = {co_cellvars},")
self.write(f".co_freevars = {co_freevars},")
self.deallocs.append(f"_PyStaticCode_Dealloc(&{name});")
self.patchups.append(f"_PyStaticCode_InternStrings(&{name});")
return f"& {name}.ob_base"

def generate_tuple(self, name: str, t: Tuple[object, ...]) -> str:
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.