[Numpy-svn] r8218 - trunk/doc

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 20:51:48 CST 2010

Author: ptvirtan
Date: 2010-02-20 20:51:48 -0600 (Sat, 20 Feb 2010)
New Revision: 8218

3K: doc: note about consequences of removed Py_TPFLAGS_CHECKTYPES

Modified: trunk/doc/Py3K.txt
--- trunk/doc/Py3K.txt	2010-02-21 02:51:34 UTC (rev 8217)
+++ trunk/doc/Py3K.txt	2010-02-21 02:51:48 UTC (rev 8218)
@@ -263,7 +263,28 @@
 These use Py_SIZE, etc. macros now.  The macros are also defined in
 npy_3kcompat.h for the Python versions that don't have them natively.
+Python 3 no longer supports type coercion in arithmetic.
+Py_TPFLAGS_CHECKTYPES is now on by default, and so the C-level
+interface, ``nb_*`` methods, still unconditionally receive whatever
+types as their two arguments.
+However, this will affect Python-level code: previously if you
+inherited from a Py_TPFLAGS_CHECKTYPES enabled class that implemented
+a ``__mul__`` method, the same ``__mul__`` method would still be
+called also as when a ``__rmul__`` was required, but with swapped
+arguments (see Python/Objects/typeobject.c:wrap_binaryfunc_r).
+However, on Python 3, arguments are swapped only if both are of same
+(sub-)type, and otherwise things fail.
+This means that ``ndarray``-derived subclasses must now implement all
+relevant ``__r*__`` methods, since they cannot any more automatically
+fall back to ndarray code.

More information about the Numpy-svn mailing list