Support __index__() in getrandbits(), randbytes() and others
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Feature or enhancement
Support of the __index__() method in getrandbits() and randbytes() is inconsistent.
Random.getrandbits()supports__index__(), butSystemRandom.getrandbits()does not.SystemRandom.randbytes()supports__index__(), butRandom.randbytes()does not.
For consistence, both classes should support it.
sample() fails if its k argument is not integer. k should have __index__(), but it also should support comparison with integers and multiplication by list and integer. It is easy to make it more general, and only require __index__(). It will also produce more meaningful error.
binomialvariate() seems "working" with non-integer n argument, but the result is questionable. Passing non-integer value is most likely an error, and it would be better to detect it.
cc @rhettinger
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Finde die Implementierungen und Tests für Random.getrandbits(), SystemRandom.getrandbits(), Random.randbytes(), SystemRandom.randbytes(), sample() und binomialvariate(). Vergleiche deren Behandlung von Argumenten, die keine Ganzzahlen sind, und überprüfe anschließend, dass unterstützte Argumente konsistent index() verwenden und ungültige Eingaben für binomialvariate() abgelehnt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100