Skip to content
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

(perf): use a rvalue cast in func_wrapper #3966

Merged

Conversation

Skylion007
Copy link
Collaborator

@Skylion007 Skylion007 commented May 21, 2022

Description

PR: #3949 Fixed rvalue casts to python objects. This allows us to do an rvalue cast on the return values from func_wrappers. This optimization removes an extra incref, decref, and may further optimize the ctors / dtor in C++17 through ellision depending on the return type.

Suggested changelog entry:

* (perf): optimize c++ to python function casting by using the rvalue caster.

@Skylion007 Skylion007 requested review from rwgk and henryiii May 21, 2022 15:52
@Skylion007 Skylion007 changed the title (perf): use an rvalue cast in func_wrapper (perf): use a rvalue cast in func_wrapper May 21, 2022
@Skylion007 Skylion007 merged commit c42414d into pybind:master May 23, 2022
@Skylion007 Skylion007 deleted the skylion007/rvalue-funcwrapper-optimize branch May 23, 2022 16:26
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label May 23, 2022
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Jul 7, 2022
EricCousineau-TRI added a commit to EricCousineau-TRI/pybind11 that referenced this pull request Oct 17, 2023
* (perf): use an rvalue cast in func_wrapper

* Try to clarify comment

* Fix comment typo
# Conflicts:
#	include/pybind11/functional.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants