summaryrefslogtreecommitdiff
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-09-10 17:05:20 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-09-10 17:05:57 +0300
commiteb84a830df62813f5af7f0144fc77444bf18f3a8 (patch)
treec75036150f3584486bc2064572faa2fe2750ae8c /py/mpconfig.h
parentde981040b392685b0d7f2381a63526b71e633b9c (diff)
py/runtime: Implement dispatch for "reverse op" special methods.
If, for class X, X.__add__(Y) doesn't exist (or returns NotImplemented), try Y.__radd__(X) instead. This patch could be simpler, but requires undoing operand swap and operation switch to get non-confusing error message in case __radd__ doesn't exist.
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 38cf4b560..63438a846 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -759,11 +759,19 @@ typedef double mp_float_t;
#endif
// Whether to support complete set of special methods
-// for user classes, otherwise only the most used
+// for user classes, or only the most used ones. "Reverse"
+// methods are controlled by MICROPY_PY_REVERSE_SPECIAL_METHODS
+// below.
#ifndef MICROPY_PY_ALL_SPECIAL_METHODS
#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
#endif
+// Whether to support reverse arithmetic operarions methods
+// (__radd__, etc.)
+#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS
+#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
+#endif
+
// Whether to support compile function
#ifndef MICROPY_PY_BUILTINS_COMPILE
#define MICROPY_PY_BUILTINS_COMPILE (0)