Josiah Carlson wrote: > I just thought of a better way of benchmarking list-like over-allocation > semantics.
here's another way: $ more Objects/unicodeobject.c ... PyObject * PyUnicode_Join(PyObject *separator, PyObject *seq) { size_t res_alloc = 100; /* # allocated bytes for string in res */ ... if (new_res_used > res_alloc) { /* double allocated size until it's big enough */ do { size_t oldsize = res_alloc; res_alloc += res_alloc; if (res_alloc < oldsize || res_alloc > INT_MAX) goto Overflow; } while (new_res_used > res_alloc); if (_PyUnicode_Resize(&res, (int)res_alloc) < 0) { Py_DECREF(item); goto onError; } res_p = PyUnicode_AS_UNICODE(res) + res_used; } ... </F> _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com