summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2010-02-21 02:51:48 +0000
committerPauli Virtanen <pav@iki.fi>2010-02-21 02:51:48 +0000
commit1c60ede5f42721319ce9fa7337d6539cea9f97f7 (patch)
tree85044bbb7846e81709ec003e8d2f6c26ff59eaf4 /doc
parent84211286b98f6f3bfb1feeaaa0f0b3ed7bbbd6e3 (diff)
downloadnumpy-1c60ede5f42721319ce9fa7337d6539cea9f97f7.tar.gz
3K: doc: note about consequences of removed Py_TPFLAGS_CHECKTYPES
Diffstat (limited to 'doc')
-rw-r--r--doc/Py3K.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/doc/Py3K.txt b/doc/Py3K.txt
index 406375a11..9cb8da8bb 100644
--- a/doc/Py3K.txt
+++ b/doc/Py3K.txt
@@ -263,6 +263,27 @@ ob_type, ob_size
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.
+Py_TPFLAGS_CHECKTYPES
+---------------------
+
+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.
+
PyNumberMethods
---------------