Opened 7 years ago

Closed 7 years ago

#5761 closed (invalid)

Use random.sample, don't reimplement it

Reported by: Nir Soffer <nirs@…> Owned by: nobody
Component: Contrib apps Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mboersma)

Python's standard library since 2.3 has had random.sample for choosing random elements of a sequence. In contrib/auth/models.py, the implementor was unaware of this and wrote a bit more code than needed.

Attachments (2)

password.diff (868 bytes) - added by Nir Soffer <nirs@…> 7 years ago.
patch
5761.diff (758 bytes) - added by mboersma 7 years ago.
Similar patch against django trunk as of [6534].

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by Nir Soffer <nirs@…>

patch

comment:1 Changed 7 years ago by mboersma

  • Component changed from Uncategorized to Contrib apps
  • Description modified (diff)
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Minor refactoring to Use random.sample, don't reimplement it
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 0.96 to SVN

I changed the title and description to be clearer, and updated it to Django-SVN, since 0.96 won't get patched for this, and it's still there in trunk.

Changed 7 years ago by mboersma

Similar patch against django trunk as of [6534].

comment:2 Changed 7 years ago by SmileyChris

  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

random.sample samples without replacement. The existing code is equivalent to sampling with replacement.

Note: See TracTickets for help on using tickets.
Back to Top