Skip to content

clib: Switch the order of if-conditions to improve the Session.call_module performance#3502

Merged
seisman merged 2 commits intomainfrom
refactor/call_module
Oct 11, 2024
Merged

clib: Switch the order of if-conditions to improve the Session.call_module performance#3502
seisman merged 2 commits intomainfrom
refactor/call_module

Conversation

@seisman
Copy link
Member

@seisman seisman commented Oct 10, 2024

Description of proposed changes

In the old version, we first check if args is a string, if not then check if it's a list. The codes are like:

if isinstance(args, str):
    ...
elif isinstance(args, list):
    ...

Since in most cases, args is a list, it's better to check against list first, then string. In this way, the first if-condition is True, so it's slightly faster, although the performance improvement can be negligible.

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. run/benchmark Trigger the benchmark workflow in PRs labels Oct 10, 2024
@seisman seisman added this to the 0.14.0 milestone Oct 10, 2024
@michaelgrund michaelgrund added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Oct 10, 2024
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
@seisman seisman merged commit 1d7cf5c into main Oct 11, 2024
@seisman seisman deleted the refactor/call_module branch October 11, 2024 00:05
@seisman seisman removed final review call This PR requires final review and approval from a second reviewer run/benchmark Trigger the benchmark workflow in PRs labels Oct 11, 2024
seisman added a commit that referenced this pull request Oct 16, 2024
…odule performance (#3502)

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants