Skip to content

bpo-26415: reduce peak memory consumption by the parser #10995

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ Doc/library/token-list.inc linguist-generated=true
Include/token.h linguist-generated=true
Lib/token.py linguist-generated=true
Parser/token.c linguist-generated=true
Modules/gramvalid.c linguist-generated=true
1 change: 1 addition & 0 deletions Include/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ PyAPI_FUNC(node *) PyNode_New(int type);
PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
char *str, int lineno, int col_offset,
int end_lineno, int end_col_offset);
PyAPI_FUNC(void) PyNode_Compress(node *n);
PyAPI_FUNC(void) PyNode_Free(node *n);
#ifndef Py_LIMITED_API
PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
Expand Down
4 changes: 3 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,11 @@ regen-grammar: regen-token
$(PYTHON_FOR_REGEN) -m Parser.pgen $(srcdir)/Grammar/Grammar \
$(srcdir)/Grammar/Tokens \
$(srcdir)/Include/graminit.h.new \
$(srcdir)/Python/graminit.c.new
$(srcdir)/Python/graminit.c.new \
$(srcdir)/Modules/gramvalid.c.new
$(UPDATE_FILE) $(srcdir)/Include/graminit.h $(srcdir)/Include/graminit.h.new
$(UPDATE_FILE) $(srcdir)/Python/graminit.c $(srcdir)/Python/graminit.c.new
$(UPDATE_FILE) $(srcdir)/Modules/gramvalid.c $(srcdir)/Modules/gramvalid.c.new

.PHONY=regen-ast
regen-ast:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Reduce peak memory consumption by the parser, by compressing some
branchless stretches in the parse tree into a single node. AST is
not affected.
Loading