[Python-checkins] r69996 - in python/branches/py3k: Lib/test/test_opcodes.py Python/ceval.c Tools/scripts/README Tools/scripts/analyze_dxp.py
benjamin.peterson
python-checkins at python.org
Thu Feb 26 19:55:48 CET 2009
Author: benjamin.peterson
Date: Thu Feb 26 19:55:48 2009
New Revision: 69996
Log:
Merged revisions 69811,69947 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69811 | collin.winter | 2009-02-20 13:30:41 -0600 (Fri, 20 Feb 2009) | 2 lines
Issue 5176: special-case string formatting in BINARY_MODULO implementation. This shows a modest (1-3%) speed-up in templating systems, for example.
........
r69947 | jeffrey.yasskin | 2009-02-24 16:48:34 -0600 (Tue, 24 Feb 2009) | 3 lines
Tools/scripts/analyze_dxp.py, a module with some helper functions to
analyze the output of sys.getdxp().
........
Added:
python/branches/py3k/Tools/scripts/analyze_dxp.py
- copied unchanged from r69947, /python/trunk/Tools/scripts/analyze_dxp.py
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/test/test_opcodes.py
python/branches/py3k/Python/ceval.c
python/branches/py3k/Tools/scripts/README
Modified: python/branches/py3k/Lib/test/test_opcodes.py
==============================================================================
--- python/branches/py3k/Lib/test/test_opcodes.py (original)
+++ python/branches/py3k/Lib/test/test_opcodes.py Thu Feb 26 19:55:48 2009
@@ -98,6 +98,12 @@
g = eval('lambda a=1: None')
self.assertNotEquals(f, g)
+ def test_modulo_of_string_subclasses(self):
+ class MyString(str):
+ def __mod__(self, value):
+ return 42
+ self.assertEqual(MyString() % 3, 42)
+
def test_main():
run_unittest(OpcodeTest)
Modified: python/branches/py3k/Python/ceval.c
==============================================================================
--- python/branches/py3k/Python/ceval.c (original)
+++ python/branches/py3k/Python/ceval.c Thu Feb 26 19:55:48 2009
@@ -1446,7 +1446,10 @@
TARGET(BINARY_MODULO)
w = POP();
v = TOP();
- x = PyNumber_Remainder(v, w);
+ if (PyUnicode_CheckExact(v))
+ x = PyUnicode_Format(v, w);
+ else
+ x = PyNumber_Remainder(v, w);
Py_DECREF(v);
Py_DECREF(w);
SET_TOP(x);
Modified: python/branches/py3k/Tools/scripts/README
==============================================================================
--- python/branches/py3k/Tools/scripts/README (original)
+++ python/branches/py3k/Tools/scripts/README Thu Feb 26 19:55:48 2009
@@ -4,6 +4,7 @@
See also the Demo/scripts directory!
+analyze_dxp.py Analyzes the result of sys.getdxp()
byext.py Print lines/words/chars stats of files by extension
byteyears.py Print product of a file's size and age
checkappend.py Search for multi-argument .append() calls
More information about the Python-checkins
mailing list