Skip to content

Commit fd91bef

Browse files
author
raymond.hettinger
committed
Issue 3116: fix quadratic behavior in marshal.dumps().
git-svn-id: http://svn.python.org/projects/python/trunk@64303 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 85bac08 commit fd91bef

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Core and Builtins
5050
Extension Modules
5151
-----------------
5252

53+
- Issue #3116: marshal.dumps() had quadratic behavior for strings > 32Mb.
54+
5355
- Issue #2138: Add factorial() the math module.
5456

5557
- The heapq module does comparisons using LT instead of LE. This

Python/marshal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ w_more(int c, WFILE *p)
6767
size = PyString_Size(p->str);
6868
newsize = size + size + 1024;
6969
if (newsize > 32*1024*1024) {
70-
newsize = size + 1024*1024;
70+
newsize = size + (size >> 3); /* 12.5% overallocation */
7171
}
7272
if (_PyString_Resize(&p->str, newsize) != 0) {
7373
p->ptr = p->end = NULL;

0 commit comments

Comments
 (0)