GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecate the optional *random* argument to random.shuffle() · Issue #84645 · python/cpython

Deprecate the optional *random* argument to random.shuffle() #84645

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate the optional *random* argument to random.shuffle()#84645
Copy link
Labels
3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@rhettinger
rhettinger
opened on May 1, 2020
Issue body actions
BPO 40465
Nosy @tim-one, @rhettinger, @vstinner, @serhiy-storchaka, @hugovk
PRs
  • bpo-40465: Deprecate the optional argument to random.shuffle(). #19867
  • bpo-40465: Remove random module features deprecated in 3.9 #25874
  • bpo-40465: Document random module changes in 3.11 What's new #31818
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-05-02.23:49:03.587>
    created_at = <Date 2020-05-01.08:31:41.792>
    labels = ['type-bug', 'library', '3.9']
    title = 'Deprecate the optional *random* argument to random.shuffle()'
    updated_at = <Date 2022-03-24.13:29:22.965>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2022-03-24.13:29:22.965>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-02.23:49:03.587>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2020-05-01.08:31:41.792>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40465
    keywords = ['patch']
    message_count = 8.0
    messages = ['367826', '367828', '367948', '370417', '370418', '415418', '415940', '415941']
    nosy_count = 5.0
    nosy_names = ['tim.peters', 'rhettinger', 'vstinner', 'serhiy.storchaka', 'hugovk']
    pr_nums = ['19867', '25874', '31818']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40465'
    versions = ['Python 3.9']

    Activity

    1. rhettinger commented on May 1, 2020

      @rhettinger
      rhettinger
      on May 1, 2020
      ContributorAuthor
      More actions

      shuffle(x, random=None) ⟼ shuffle(x)

      AFAICT, no one ever uses the optional parameter, nor would they have a valid reason to do so. It is an ancient API oddity and is inconsistent with the other methods in the module. I've long been annoyed by it and would like to see it cleaned-up before I retire ;-)

      https://docs.python.org/3/library/random.html#random.shuffle

    2. rhettinger
      added
      3.9 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on May 1, 2020
    3. serhiy-storchaka commented on May 1, 2020

      @serhiy-storchaka
      serhiy-storchaka
      on May 1, 2020
      Member
      More actions

      +1

    4. rhettinger commented on May 2, 2020

      @rhettinger
      rhettinger
      on May 2, 2020
      ContributorAuthor
      More actions

      New changeset 190fac9 by Raymond Hettinger in branch 'master':
      bpo-40465: Deprecate the optional argument to random.shuffle(). (bpo-19867)
      190fac9

    5. rhettinger
      closed this as completedon May 2, 2020
    6. rhettinger
      closed this as completedon May 2, 2020
    7. asottile commented on May 31, 2020

      @asottile
      asottilemannequin
      on May 31, 2020
      Mannequin
      More actions

      pre-commit uses this to do deterministic shuffling, please don't remove this

      pre-commit/pre-commit#1479

    8. serhiy-storchaka commented on May 31, 2020

      @serhiy-storchaka
      serhiy-storchaka
      on May 31, 2020
      Member
      More actions

      Raymond, could you please add an entry in What's New?

    9. hugovk commented on Mar 17, 2022

      @hugovk
      hugovk
      on Mar 17, 2022
      Member
      More actions

      #75999 adds an entry to What's New in 3.11.

    10. serhiy-storchaka commented on Mar 24, 2022

      @serhiy-storchaka
      serhiy-storchaka
      on Mar 24, 2022
      Member
      More actions

      New changeset 12c0012 by Tomáš Hrnčiar in branch 'main':
      bpo-40465: Document random module changes in 3.11 What's new (bpo-31818)
      12c0012

    11. vstinner commented on Mar 24, 2022

      @vstinner
      vstinner
      on Mar 24, 2022
      Member
      More actions

      commit 70a071d
      Author: Raymond Hettinger <[email protected]>
      Date: Tue May 4 01:55:40 2021 -0700

      bpo-40465: Remove random module features deprecated in 3.9 (GH-25874)
      
    12. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    13. exarkun
      added a commit that references this issue on Feb 13, 2023

      Remove the explicit `random` parameter from `setlist.shuffle`

      f6407d7
    14. shaperilio commented on Aug 23, 2023

      @shaperilio
      shaperilio
      on Aug 23, 2023
      More actions

      AFAICT, no one ever uses the optional parameter, nor would they have a valid reason to do so. It is an ancient API oddity and is inconsistent with the other methods in the module. I've long been annoyed by it and would like to see it cleaned-up before I retire ;-)

      Wow, what a bold statement 🤣. We were using it. Hope you're enjoying retirement.

      Can someone help me understand the motivation for this? I keep clicking on links trying to figure it out if there was a bug associated with this, but I'm not familiar with the issue tracking here.

      Reacted by Jan Kaliszewski
    15. serhiy-storchaka commented on Aug 23, 2023

      @serhiy-storchaka
      serhiy-storchaka
      on Aug 23, 2023
      Member
      More actions
      1. It complicated the code.
      2. When that argument was specified, the result was less random.
      3. The design just looked wrong.
      Reacted by Tim Peters
    16. tim-one commented on Aug 23, 2023

      @tim-one
      tim-one
      on Aug 23, 2023
      Member
      More actions

      The default implementation of shuffle() stopped using random() long ago - it switched to a method avoiding floats entirely, and also avoiding the slight statistical biases the come with using floats for this.

      So if you passed random= after that change, it went back to using the older - different & inherently biased - algorithm.

      Keeping a worse algorithm in the code base was a Bad Idea on the face of it, especially given that nobody looking at this knew of anyone actually using the optional argument.

      In the very early days, Python used the feeble (by current standards) Wichmann–Hill generator. Then there was far more user interest in replacing it with something better, even if slower. For the far fewer users who still care about that, there's a documented way to subclass Random now to use whatever other underlying generator you like better, and in a way that affects all the methods (not just shuffle()) building on the underlying generator.

      Reacted by Emilio Graff and Arlo Faria
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.