Restore (or beat) Python 2 performance for arithmetic operations on ints that fit into a single word

Open
#101,291 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start with the fuller discussion in faster-cpython/ideas#548, then review the linked pull requests gh-101292, gh-101685, gh-102464, gh-104742, gh-104759, gh-107388, gh-107392, gh-125384, gh-125407, and gh-125408. Done would mean a new int/long object layout that restores or exceeds Python 2 performance for arithmetic on single-word integers.

Written by the indexing model from the issue text.

Description

interpreter-core performance

In Python 2 ints and longs were different objects, and the design of each was tailored to the different size and use cases.
In Python3 we dropped the distinction, but we also dropped the design for ints that fit into a single word.
We have added various fast paths for "medium" integers (e.g. https://github.com/python/cpython/issues/89109) but the underlying data structure gets in the way.

We should layout the int/long object so that it supports fast operations for most integers.

See https://github.com/faster-cpython/ideas/issues/548 for a fuller discussion

Linked PRs
  • gh-101292
  • gh-101685
  • gh-102464
  • gh-104742
  • gh-104759
  • gh-107388
  • gh-107392
  • gh-125384
  • gh-125407
  • gh-125408
Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.