STINNER Victor <vstin...@python.org> added the comment:
Example with Python 3.8: --- import random class MyRandom(random.Random): def getrandbits(self, n): return 0 my = MyRandom() print([my.randint(1, 6) for _ in range(3)]) print([my.random() for _ in range(3)]) --- Output: --- [1, 1, 1] [0.5654641798814677, 0.610057019404943, 0.7526620665660224] --- [1, 1, 1] is what I expect, but what are these random [0.5654641798814677, 0.610057019404943, 0.7526620665660224] numbers? This behavior is surprising me. I would expect the base class to be "empty", not to inherit Mersenne Twister. If I don't implement all required abstract methods: I would either expect an error when the class is created, or at least when the method is called. Raymond: > Am not sure I'm comfortable with you defining random() in pure python > dividing by BPF -- that seems like a C level decision. My PR 19631 doesn't change random.Random.random() (still implemented in C) nor random.SystemRandom.random() (same Python implementation): they should produce exactly the same random floating point numbers. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40346> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com