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

Add skip_verbose_naming in add_hook to give an option for skipping the naming #635

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

verlocks
Copy link

Description

Like the proposal mentioned in issue, running full_hook._name_ = (hook._repr_()) in add_hook may cause large overhead in some situation. This PR add a new parameter skip_verbose_naming that allows user to skip this line.

Fixes #631

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Screenshots

The overhead caused by naming being removed by adding skip_verbose_naming=True in with model.hooks(fwd_hooks=fwd_hooks, skip_verbose_naming=True):.

Before
image
After
image

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

There is some problem with the current unit test here:
image
After my changes, the parameter would be different for add_hook. Should I do anything about it?

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.

[Proposal] Remove the overhead caused by full_hook.__name__ = (hook.__repr__())?
2 participants