diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-04-14 16:44:10 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-04-14 16:44:10 (GMT) |
commit | af03757d20a13b4090d06e0a198122be194aa6b0 (patch) | |
tree | aecef262f4fc65205624efe127afa1ccac0247c5 /Objects/object.c | |
parent | 322cc7438c081e19d0402f53e720d6b0cd58b227 (diff) | |
download | cpython-af03757d20a13b4090d06e0a198122be194aa6b0.zip cpython-af03757d20a13b4090d06e0a198122be194aa6b0.tar.gz cpython-af03757d20a13b4090d06e0a198122be194aa6b0.tar.bz2 |
Optimize ascii(str): don't encode/decode repr if repr is already ASCII
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index fd1fd25..79f1c8a 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -451,6 +451,9 @@ PyObject_ASCII(PyObject *v) if (repr == NULL) return NULL; + if (PyUnicode_IS_ASCII(repr)) + return repr; + /* repr is guaranteed to be a PyUnicode object by PyObject_Repr */ ascii = _PyUnicode_AsASCIIString(repr, "backslashreplace"); Py_DECREF(repr); |