Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 18129:9d533ae574d2 legacy-trunk
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.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Sat, 16 Jun 2001 05:11:17 +0000 |
| parents | 592109f2a6fd |
| children | 8eea2efb34cd |
line wrap: on
line diff
--- a/Objects/stringobject.c Sat Jun 16 00:09:28 2001 +0000 +++ b/Objects/stringobject.c Sat Jun 16 05:11:17 2001 +0000 @@ -1031,6 +1031,23 @@ 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) {
