2

I've just noticed that numpy.random.randint and random.randint have very similar names but they have slightly different definitions. Randomness and performance differences aside, as here and here, I'm surprised that the end number for numpy.random is exclusive while in random is inclusive.

Looking at the documentation

numpy.random.randint(low, high=None, size=None, dtype='l') Return random integers from low (inclusive) to high (exclusive).

while

random.randint(a, b): Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).

I must say that random convention to include b is less pythonic, as it feels inconsistent with, say, range.

In any case, my question is What other examples of common look-alike but different functions I must be aware of?

EA304GT
  • 634
  • 8
  • 11

0 Answers0