Merged
Conversation
sl0thentr0py
reviewed
Nov 4, 2022
| elif hasattr( | ||
| receiver, "func" | ||
| ): # certain functions (like partials) dont have a name | ||
| name = "partial(<function " + receiver.func.__name__ + ">)" # type: ignore |
Member
There was a problem hiding this comment.
can the func itself be a partial?
Contributor
Author
There was a problem hiding this comment.
F*ck... Probably... I will check on Monday
Contributor
Author
There was a problem hiding this comment.
I will check now.
Contributor
Author
There was a problem hiding this comment.
Ok, func appears to always be the function:
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a, b, c, x):
... return 1000*a + 100*b + 10*c + x
...
>>> f
<function f at 0x102752050>
>>> from functools import partial
>>> g = partial(f, 3)
>>> h = partial(g, 1)
>>> g
functools.partial(<function f at 0x102752050>, 3)
>>> h
functools.partial(<function f at 0x102752050>, 3, 1)
>>> h(3, 4)
3134
>>> h.func
<function f at 0x102752050>
>>> g.func
<function f at 0x102752050>
sl0thentr0py
approved these changes
Nov 4, 2022
Member
sl0thentr0py
left a comment
There was a problem hiding this comment.
change is fine, but why was it slow in the first place?
Contributor
Author
|
Because I will see if the user can test this and confirm that it makes the situation way better before I merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our Django signals integrations added a lot of overhead in some cases.
See: #1721
This code runs now over an order of magnitude faster for getting the name of a partials.
Closes #1721