diff options
author | Raymond Hettinger <python@rcn.com> | 2008-06-16 01:49:18 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-06-16 01:49:18 (GMT) |
commit | 75ee9eb9c60cc85925d2bfe9f92f2b2da81ddefd (patch) | |
tree | daabb3dbcf71c4ec6b6a8bba1e3a440f6b317b87 /Python | |
parent | d297f1ad78f1058c62bf47c2f1e2c2488f7e9d25 (diff) | |
download | cpython-75ee9eb9c60cc85925d2bfe9f92f2b2da81ddefd.zip cpython-75ee9eb9c60cc85925d2bfe9f92f2b2da81ddefd.tar.gz cpython-75ee9eb9c60cc85925d2bfe9f92f2b2da81ddefd.tar.bz2 |
Issue #3116 and #1792: Fix quadratic behavior in marshal.dumps().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/marshal.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/marshal.c b/Python/marshal.c index 897c15e..c305bbe 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -65,7 +65,10 @@ w_more(int c, WFILE *p) if (p->str == NULL) return; /* An error already occurred */ size = PyString_Size(p->str); - newsize = size + 1024; + newsize = size + size + 1024; + if (newsize > 32*1024*1024) { + newsize = size + (size >> 3); /* 12.5% overallocation */ + } if (_PyString_Resize(&p->str, newsize) != 0) { p->ptr = p->end = NULL; } |