]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Intern 1-character strings as soon as they're created. As-is, they aren't
authorTim Peters <tim.peters@gmail.com>
Tue, 8 May 2001 22:33:50 +0000 (22:33 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 8 May 2001 22:33:50 +0000 (22:33 +0000)
commit5b4d47756871a11621dc4d96e58a9180479704f3
tree5cac00d2457b3fa2b112471344b97618d859527d
parent61dff2b285249485ab2f57f7200d4c50b741c610
Intern 1-character strings as soon as they're created.  As-is, they aren't
interned when created, so the cached versions generally aren't ever
interned.  With the patch, the
Py_INCREF(t);
*p = t;
Py_DECREF(s);
return;
indirection block in PyString_InternInPlace() is never executed during a
full run of the test suite, but was executed very many times before.  So
I'm trading more work when creating one-character strings for doing less
work later.  Note that the "more work" here can happen at most 256 times
per program run, so it's trivial.  The same reasoning accounts for the
patch's simplification of string_item (the new version can call
PyString_FromStringAndSize() no more than 256 times per run, so there's
no point to inlining that stuff -- if we were serious about saving time
here, we'd pre-initialize the characters vector so that no runtime testing
at all was needed!).
Objects/stringobject.c