Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 51759:0848ebb8f9c8 legacy-trunk
Issue 5176: special-case string formatting in BINARY_MODULO implementation. This shows a modest (1-3%) speed-up in templating systems, for example.
| author | Collin Winter <collinw@gmail.com> |
|---|---|
| date | Fri, 20 Feb 2009 19:30:41 +0000 |
| parents | 994fe4df4af7 |
| children | ef8fe9088696 |
line wrap: on
line diff
--- a/Python/ceval.c Fri Feb 20 14:02:36 2009 +0000 +++ b/Python/ceval.c Fri Feb 20 19:30:41 2009 +0000 @@ -1283,7 +1283,10 @@ case BINARY_MODULO: w = POP(); v = TOP(); - x = PyNumber_Remainder(v, w); + if (PyString_CheckExact(v)) + x = PyString_Format(v, w); + else + x = PyNumber_Remainder(v, w); Py_DECREF(v); Py_DECREF(w); SET_TOP(x);
