Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

cpython: Issue #14687: Optimize str%args

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

May 1, 2012, 4:19 PM

Post #1 of 1 (43 views)
Permalink
cpython: Issue #14687: Optimize str%args

http://hg.python.org/cpython/rev/4b98ce6ef95e
changeset: 76705:4b98ce6ef95e
user: Victor Stinner <victor.stinner [at] gmail>
date: Wed May 02 00:29:36 2012 +0200
summary:
Issue #14687: Optimize str%args

* formatfloat() uses unicode_fromascii() instead of PyUnicode_DecodeASCII()
to not have to check characters, we know that it is really ASCII
* Use PyUnicode_FromOrdinal() instead of _PyUnicode_FromUCS4() to format
a character: if avoids a call to ucs4lib_find_max_char() to compute
the maximum character (whereas we already know it, it is just the character
itself)

files:
Objects/unicodeobject.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13431,7 +13431,7 @@
(flags & F_ALT) ? Py_DTSF_ALT : 0, NULL);
if (p == NULL)
return NULL;
- result = PyUnicode_DecodeASCII(p, strlen(p), NULL);
+ result = unicode_fromascii((unsigned char*)p, strlen(p));
PyMem_Free(p);
return result;
}
@@ -13947,7 +13947,7 @@
Py_UCS4 ch = formatchar(v);
if (ch == (Py_UCS4) -1)
goto onError;
- temp = _PyUnicode_FromUCS4(&ch, 1);
+ temp = PyUnicode_FromOrdinal(ch);
break;
}


--
Repository URL: http://hg.python.org/cpython

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.