summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-02-14 23:17:06 +1100
committerDamien George <damien.p.george@gmail.com>2018-02-14 23:17:06 +1100
commitd77da83d55c5de4768720fa578b9ffa5ec502dc6 (patch)
tree83af1a61c38ea661736c75f86b2d0ab7cc67a96e /py/mpconfig.h
parent5604b710c2490e2a7cfd1bac6cd60fc2c8527a37 (diff)
downloadmicropython-d77da83d55c5de4768720fa578b9ffa5ec502dc6.tar.gz
micropython-d77da83d55c5de4768720fa578b9ffa5ec502dc6.zip
py/objrange: Implement (in)equality comparison between range objects.
This feature is not often used so is guarded by the config option MICROPY_PY_BUILTINS_RANGE_BINOP which is disabled by default. With this option disabled MicroPython will always return false when comparing two range objects for equality (unless they are exactly the same object instance). This does not match CPython so if (in)equality between range objects is needed then this option should be enabled. Enabling this option costs between 100 and 200 bytes of code space depending on the machine architecture.
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index f2a8c98cbb..b8a96f0b0a 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -787,6 +787,14 @@ typedef double mp_float_t;
#define MICROPY_PY_BUILTINS_RANGE_ATTRS (1)
#endif
+// Whether to support binary ops [only (in)equality is defined] between range
+// objects. With this option disabled all range objects that are not exactly
+// the same object will compare as not-equal. With it enabled the semantics
+// match CPython and ranges are equal if they yield the same sequence of items.
+#ifndef MICROPY_PY_BUILTINS_RANGE_BINOP
+#define MICROPY_PY_BUILTINS_RANGE_BINOP (0)
+#endif
+
// Whether to support timeout exceptions (like socket.timeout)
#ifndef MICROPY_PY_BUILTINS_TIMEOUTERROR
#define MICROPY_PY_BUILTINS_TIMEOUTERROR (0)