The documentation claims:

Samples elements from [0,..,len(weights)-1] with given probabilities (weights).

I agree that this might not be a sufficiently detailed explanations for some users and I’m sure PRs are welcome to improve the docs