Skip to content

bpo-47189: What's New in 3.11: Faster CPython #32235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 6, 2022

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Apr 1, 2022

The static objects section's credits go to Kumar Aditya.

TODO:

  • Lazy __dict__ optimizations
  • [ ] dict memory saving optimizations by Inada-san, but I have no clue where to start for those

https://bugs.python.org/issue47189

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Apr 1, 2022
@Fidget-Spinner Fidget-Spinner changed the title What's New in 3.11: Faster CPython bpo-47189: What's New in 3.11: Faster CPython Apr 1, 2022
@Fidget-Spinner
Copy link
Member Author

CC @gvanrossum @markshannon @brandtbucher @iritkatriel @sweeneyde @corona10 @kumaraditya303 @JelleZijlstra. For your opinions and review please (especially on the parts y'all contributed).

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, It is a great honor to see my name on the list.

@markshannon
Copy link
Member

Thank you, It is a great honor to see my name on the list.

You deserve it.

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. It is much appreciated.
I've left a few comments.

@@ -62,6 +62,7 @@ Summary -- Release highlights
.. This section singles out the most important changes in Python 3.11.
Brevity is key.

- Python 3.11 is 22% faster than Python 3.10. See `Faster CPython`_ for details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather claim a range, say 10% to 60%.

Once the latest PRs are merged it will be about 25%, if you must have a single number.

https://gist.github.com/markshannon/bf1b99177290db30dd0ab8f56446d0ea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update this number when the benchmark link updates its values/ when those PRs are merged into main.

@Fidget-Spinner
Copy link
Member Author

@pablogsal are you OK with this going into 3.11 whats new? Or would you prefer I host this somewhere else and link to it in the whatsnew?

@pablogsal
Copy link
Member

@pablogsal are you OK with this going into 3.11 whats new? Or would you prefer I host this somewhere else and link to it in the whatsnew?

For the time leave it here in its own section as in this way I will be able to easily do the final edits. Removing or moving information is much easier to add it as that way I don't need to consider what may be missing :)

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put my nit-picking hat on while reviewing this. :-) Overall great work, and can't wait to see this show up on docs.python.org!

Comment on lines 624 to 625
| | | Calls to certain Python functions are inlined similar | | |
| | | to :ref:`inline-calls`. | | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an oblique reference to PRECALL_NO_KW_METHOD_DESCRIPTOR_O? Or does it refer to something else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it just means that CALL_FUNCTION_EX for things like f(1, 2, *args, **kwargs) aren't inlined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. It's rather subtle what you intend to say then. The text linked under inline-calls already describes Python-to-Python calls. But they are described here again because specialization adds... what again? It feels like claiming credit for the same optimization in two places. I do realize that there are two separate code changes, but to the readers of a high-level document like this that seems a bit too subtle.

Also, it's not clear for what operation you are claiming a 170% speedup (so a factor 2.7). The table layout makes it look like C(arg). But surely the speedup for class constructors is not a single extremely large number?

Fidget-Spinner and others added 2 commits April 5, 2022 18:54
Co-Authored-By: Guido van Rossum <[email protected]>
Co-Authored-By: Irit Katriel <[email protected]>
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bunch of one-character nits. :-)

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly this PR is so large and comments are flying so fast we should probably land it ASAP and then iterate.

Comment on lines 624 to 625
| | | Calls to certain Python functions are inlined similar | | |
| | | to :ref:`inline-calls`. | | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. It's rather subtle what you intend to say then. The text linked under inline-calls already describes Python-to-Python calls. But they are described here again because specialization adds... what again? It feels like claiming credit for the same optimization in two places. I do realize that there are two separate code changes, but to the readers of a high-level document like this that seems a bit too subtle.

Also, it's not clear for what operation you are claiming a 170% speedup (so a factor 2.7). The table layout makes it look like C(arg). But surely the speedup for class constructors is not a single extremely large number?

Co-Authored-By: Guido van Rossum <[email protected]>
@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Apr 6, 2022

Also, it's not clear for what operation you are claiming a 170% speedup (so a factor 2.7). The table layout makes it look like C(arg). But surely the speedup for class constructors is not a single extremely large number?

Oof the table layout worked against me. The 170% speedup is tied to "Calls to certain python functions are inlined", not C(arg). I have since removed that line altogether.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good now. Thanks very much for all your work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.