diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-06-16 05:11:17 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-06-16 05:11:17 (GMT) |
commit | a7259597f1f9ef389012010d7b8a02ebcf7396e7 (patch) | |
tree | 7ada9cc6a3f30bc41999ba56da018ccd55342df8 /Objects/stringobject.c | |
parent | 239508cd1087a521ebe40fabc96c66dcb11c3f8c (diff) | |
download | cpython-a7259597f1f9ef389012010d7b8a02ebcf7396e7.zip cpython-a7259597f1f9ef389012010d7b8a02ebcf7396e7.tar.gz cpython-a7259597f1f9ef389012010d7b8a02ebcf7396e7.tar.bz2 |
SF bug 433228: repr(list) woes when len(list) big.
Gave Python linear-time repr() implementations for dicts, lists, strings.
This means, e.g., that repr(range(50000)) is no longer 50x slower than
pprint.pprint() in 2.2 <wink>.
I don't consider this a bugfix candidate, as it's a performance boost.
Added _PyString_Join() to the internal string API. If we want that in the
public API, fine, but then it requires runtime error checks instead of
asserts.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index bcf5147..24443d8 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -1031,6 +1031,23 @@ string_join(PyStringObject *self, PyObject *args) return res; } +PyObject *_PyString_Join(PyObject *sep, PyObject *x) +{ + PyObject* args; + PyObject* result = NULL; + + assert(sep != NULL && PyString_Check(sep)); + assert(x != NULL); + args = PyTuple_New(1); + if (args != NULL) { + Py_INCREF(x); + PyTuple_SET_ITEM(args, 0, x); + result = string_join((PyStringObject *)sep, args); + Py_DECREF(args); + } + return result; +} + static long string_find_internal(PyStringObject *self, PyObject *args, int dir) { |