summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-01-22 16:19:32 +0000
committerDamien George <damien.p.george@gmail.com>2016-01-26 15:27:00 +0000
commita53af6c87540c41fdf34211ea99ee794cae6d160 (patch)
treeaf67226b9674b4643e318d53be2be117d8c52d0c /py
parentf5c42dd9d199aa61b16ad54a73531eefbb0be3eb (diff)
downloadmicropython-a53af6c87540c41fdf34211ea99ee794cae6d160.tar.gz
micropython-a53af6c87540c41fdf34211ea99ee794cae6d160.zip
extmod/modurandom: Add some extra random functions.
Functions added are: - randint - randrange - choice - random - uniform They are enabled with configuration variable MICROPY_PY_URANDOM_EXTRA_FUNCS, which is disabled by default. It is enabled for unix coverage build and stmhal.
Diffstat (limited to 'py')
-rw-r--r--py/mpconfig.h5
-rw-r--r--py/qstrdefs.h7
2 files changed, 12 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 72af343ddf..402e97acc2 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -787,6 +787,11 @@ typedef double mp_float_t;
#define MICROPY_PY_URANDOM (0)
#endif
+// Whether to include: randrange, randint, choice, random, uniform
+#ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS
+#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
+#endif
+
#ifndef MICROPY_PY_MACHINE
#define MICROPY_PY_MACHINE (0)
#endif
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index dd76c3d43b..122fca128b 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -686,4 +686,11 @@ Q(dupterm)
Q(urandom)
Q(getrandbits)
Q(seed)
+#if MICROPY_PY_URANDOM_EXTRA_FUNCS
+Q(randrange)
+Q(randint)
+Q(choice)
+Q(random)
+Q(uniform)
+#endif
#endif