PATCH: Speed up direct string concatenation by 20+%!

Fredrik Lundh fredrik at pythonware.com
Fri Sep 29 12:25:58 EDT 2006


Larry Hastings wrote:
>

> At the exact moment that the loop is done, it's a
> PyStringConcatenationObject * which points to a deep one-sided tree of
> more PyStringConcatenationObject * objects.  Its ob_sval is NULL, which
> means that the first time someone asks for its value (via the macro
> PyString_AS_STRING()) it will be computed.  When it's computed, the
> interpreter will allocate a buffer of 10000001 bytes and walk the tree,
> filling the buffer with ten million 'a's followed by a zero.  It'll
> then dereference all its children.

so what does the benchmark look like if you actually do this ?

</F>




More information about the Python-list mailing list