Skip to content

Possible optimizations for math.comb() #81476

@rhettinger

Description

@rhettinger
BPO 37295
Nosy @tim-one, @rhettinger, @mdickinson, @serhiy-storchaka, @PedanticHacker, @mcognetta, @pochmann
PRs
  • bpo-37295: Add fast path for small n in math.comb #29020
  • bpo-37295: Optimize math.comb() for small arguments #29030
  • bpo-37295: Optimize math.comb() and math.perm() #29090
  • bpo-37295: Speed up math.comb(n, k) for 0 <= k <= n <= 67 #30275
  • bpo-37295: Use constant-time comb() for larger n depending on k #30305
  • bpo-37295: More direct computation of power-of-two factor in math.comb #30313
  • Files
  • comb_with_primes.py
  • comb_with_side_limits.py: Compute limits for comb_small
  • timecomb.py
  • driver.py
  • comb_pole.py: Experiment with precomputed diagonal -- runs on 3.8 or later
  • comb_pole2.py: Precomputed k diagonal and handling for small k
  • 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 = None
    created_at = <Date 2019-06-15.19:17:40.265>
    labels = ['library', 'performance']
    title = 'Possible optimizations for math.comb()'
    updated_at = <Date 2022-01-23.22:42:15.922>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2022-01-23.22:42:15.922>
    actor = 'tim.peters'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-06-15.19:17:40.265>
    creator = 'rhettinger'
    dependencies = []
    files = ['50439', '50526', '50530', '50531', '50557', '50559']
    hgrepos = []
    issue_num = 37295
    keywords = ['patch']
    message_count = 73.0
    messages = ['345711', '345731', '345761', '345784', '345876', '345952', '345956', '404184', '404208', '404429', '404472', '406300', '406337', '406338', '406341', '407736', '408867', '408952', '408954', '408962', '408970', '408984', '408989', '408994', '409000', '409001', '409002', '409010', '409024', '409028', '409062', '409095', '409110', '409116', '409154', '409254', '409268', '409269', '409270', '409274', '409277', '409298', '409315', '409317', '409320', '409321', '409331', '409346', '409360', '409373', '409376', '409377', '409382', '409383', '409393', '409417', '409432', '410145', '410339', '410347', '410382', '410383', '410387', '410420', '410448', '410460', '410543', '410587', '410925', '410931', '411343', '411427', '411430']
    nosy_count = 7.0
    nosy_names = ['tim.peters', 'rhettinger', 'mark.dickinson', 'serhiy.storchaka', 'PedanticHacker', 'mcognetta', 'Stefan Pochmann']
    pr_nums = ['29020', '29030', '29090', '30275', '30305', '30313']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue37295'
    versions = []

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixes3.12only security fixesperformancePerformance or resource usagestdlibPython modules in the Lib dir

      Projects

      No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions