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

gh-119109: functools.partial.fallforward fix #119125

Closed
wants to merge 4 commits into from

Conversation

dg-pb
Copy link
Contributor

@dg-pb dg-pb commented May 17, 2024

#119109

I went with option 1. It is cleaner, faster and has a natural flow.

Before:

from functools import partial

def func(a, b, c=0):
    return a - b - c

p1 = partial(func, 1)

print(p1(2))    # -1
%timeit p1(2)   # 100 ns

p1.keywords['c'] = 1
print(p1(2))    # -2
%timeit p1(2)   # 234 ns

del p1.keywords['c']
print(p1(2))    # -1
%timeit p1(2)   # 144 ns

After:

p1 = partial(func, 1)

print(p1(2))    # -1
%timeit p1(2)   # 100 ns

p1.keywords['c'] = 1
print(p1(2))    # -2
%timeit p1(2)   # 234 ns

del p1.keywords['c']
print(p1(2))    # -1
%timeit p1(2)   # 100 ns

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