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 — Convert statistics sum of squares to a single pass algorithm · Issue #90415 · python/cpython

Convert statistics sum of squares to a single pass algorithm #90415

New issue
Copy link
New issue
Copy link
Closed
Closed
Convert statistics sum of squares to a single pass algorithm#90415
Copy link
Labels
3.11only security fixesonly security fixesperformancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

Description

@rhettinger
rhettinger
opened on Jan 4, 2022
Issue body actions
BPO 46257
Nosy @rhettinger, @stevendaprano
PRs
  • bpo-46257: Convert statistics._ss() to a single pass algorithm #30403
  • 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 2022-01-05.15:39:37.204>
    created_at = <Date 2022-01-04.17:04:05.171>
    labels = ['3.11', 'library', 'performance']
    title = 'Convert statistics sum of squares to a single pass algorithm'
    updated_at = <Date 2022-01-05.15:39:37.203>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2022-01-05.15:39:37.203>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-01-05.15:39:37.204>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2022-01-04.17:04:05.171>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46257
    keywords = ['patch']
    message_count = 2.0
    messages = ['409692', '409777']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'steven.daprano']
    pr_nums = ['30403']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue46257'
    versions = ['Python 3.11']

    Activity

    1. rhettinger commented on Jan 4, 2022

      @rhettinger
      rhettinger
      on Jan 4, 2022
      ContributorAuthor
      More actions

      The existing code makes two passes, one to compute the mean and another to compute the sum of squared differences from the mean. A consequence of making two passes is that iterator inputs must be converted to a list before processing. This throws away the memory saving advantages of iterators.

      The ostensible reason for the two pass code is that the single pass variant is numerically unstable when implemented with floating point accumulators. However, this code uses fractions throughout, so the accumulation is exact.

      Changing to a single pass saves memory, doubles the speed, and simplifies the upstream code in variance(), pvariance(), stdev(), and pstdev().

    2. rhettinger
      added
      3.11only security fixesonly security fixes
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      performancePerformance or resource usagePerformance or resource usage
      on Jan 4, 2022
    3. rhettinger commented on Jan 5, 2022

      @rhettinger
      rhettinger
      on Jan 5, 2022
      ContributorAuthor
      More actions

      New changeset 43aac29 by Raymond Hettinger in branch 'main':
      bpo-46257: Convert statistics._ss() to a single pass algorithm (GH-30403)
      43aac29

    4. rhettinger
      closed this as completedon Jan 5, 2022
    5. rhettinger
      closed this as completedon Jan 5, 2022
    6. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    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.11only security fixesonly security fixesperformancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory

      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.