faster-cpython icon indicating copy to clipboard operation
faster-cpython copied to clipboard

Requesting details

Open etki opened this issue 4 years ago • 3 comments

Hey, this is more of curiosity question rather something else.

Currently plan is a bit vague. May I ask for more details of what is meant by:

  • Improved performance for integers of less than one machine word.
  • Improved performance for binary operators.

And why those things are considered slow / what's wrong with them, since i have no clue of current state of things inside CPython:

  • Faster calls and returns, through better handling of frames.
  • Better object memory layout and reduced memory management overhead.

And what feature makes superior machine code superior? It would be totally OK just to explain why all those key points are currently slow if you don't want to write your concrete ideas about speeding them up.

etki avatar Nov 13 '20 19:11 etki

Improved performance for integers of less than one machine word.

Python3 uses 30 bits chunks to represent an int value in 64-bit build, or 15 bits chunks in 32-bit build. The utilization of machine word is almost halved.

If an int's value does not exceed the range of one machine word, it may be use native machine word to represent it.

There was a discussion about it: https://mail.python.org/archives/list/[email protected]/thread/L6BMMETVQYFGDIG7VIFICDSYVUXQAS52/

https://discuss.python.org/t/hybrid-implementation-for-pylongobject-performance/2129

And a very primitive prototype patch: https://github.com/animalize/cpython/pull/7/files

I gave up because I thought it make the code complex, but IMHO further attempts may be worthwhile.

I guess Mark's idea is let the interpreter support native integer (outside of int class), then it's more worth to try.

ghost avatar Nov 20 '20 05:11 ghost

hi another small question. Is the "Step1"(adaptive, specializing interpreter):

  • helping, neutral, or delaying the multiple-interpreter approach ? https://www.python.org/dev/peps/pep-0554/
  • helping, neutral or delaying the compatibility work between cpython and pypy ? thinking of HPY https://github.com/hpyproject/hpy

stonebig avatar Nov 29 '20 11:11 stonebig

Hi, Adding to the small questions list. Did the Stage 1 improvements make it into 3.10? Thanks, Howard.

hlovatt avatar Feb 06 '22 00:02 hlovatt