bpo-46939: Specialize calls to Python classes by Fidget-Spinner · Pull Request #31707 · python/cpython · GitHub

github.com

GitHub CopilotWrite better code with AI | MCP RegistryIntegrate external tools | ActionsAutomate any workflow | CodespacesInstant dev environments | IssuesPlan and track work | Code ReviewManage code changes | Code QualityEnforce quality at merge | Why GitHub | Marketplace | View all features | Enterprises | Small and medium teams | Startups | View all use cases | View all industries | View all solutions | AI | Software Development | DevOps | Security | View all topics | Customer stories | Events & webinars | Ebooks & reports | Business insights | Trust center | Partners | View all resources

Tin mới

Fidget-Spinner:specialize_py_class_calls

GitHub CopilotWrite better code with AI

GitHub Copilot appDirect agents from issue to merge

ActionsAutomate any workflow

CodespacesInstant dev environments

IssuesPlan and track work

Code ReviewManage code changes

Code QualityEnforce quality at merge

GitHub Advanced SecurityFind and fix vulnerabilities

Code securitySecure your code as you build

Secret protectionStop leaks before they start

View all use cases

Financial services

View all industries

Software Development

GitHub SponsorsFund open source developers

Copilot for BusinessEnterprise-grade AI features

Premium SupportEnterprise-grade 24/7 support

Pull requests 2.6k

Security and quality 0

Specialize calls to Python classes

awaiting core review

awaiting core review

faster-cpython/ideas#267 (comment)

I nearly went insane writing and debugging this. The general idea follows Mark's comments in faster-cpython/ideas#267 (comment). However, since we're specializing __init__, we need to return self instead of the None that

View reviewed changes

Fix segfaults, refleaks, readjust sys tests size

View reviewed changes

Learn more about hiding disruptive comments

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

fix refleak on frame exit due to exception

Use non-function pointer since it's faster

View reviewed changes

Address Jelle's review (use vectorcall for new)

View reviewed changes

https://github.com/python/cpython/pull/31707/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872R4525

_PyObject_New_Vector does some argument checking. https://github.com/python/cpython/pull/31707/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872R4525

https://github.com/python/cpython/compare/main...faster-cpython:specialize-calls-to-normal-python-classes?expand=1

This feels a bit fragile to me, but it is an interesting alternative to my approach of pushing an additional cleanup frame (https://github.com/python/cpython/compare/main...faster-cpython:specialize-calls-to-normal-pytho

Address Mark's reviews (remove func version check)

Use a macro for passing self

Merge remote-tracking branch 'upstream/main' into specialize_py_class…

Use inline caching

Regenerate frozenmain

Merge remote-tracking branch 'upstream/main' into specialize_py_class…

Drop generators from specialization

Merge branch 'main' of

https://github.com/python/cpython

Use _Py_SET_OPCODE

Specialize calls for Python classes #91095