-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Refactor] Phrase out python dependency decorator
#17661
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
Conversation
Replace decorator package with functools.wraps for simpler and more standard function wrapping. This change removes an external dependency and uses Python's built-in functools module for function decoration.
Remove the decorator package from various installation scripts and requirements files. This follows the previous refactoring of decorators to use functools.wraps, eliminating an external dependency and simplifying the project's package requirements.
5df34b0 to
ebd2ad3
Compare
Update the decorate function to create a wrapper that allows more flexible function decoration. The new implementation passes the original function as the first argument to the wrapped function, enabling more dynamic decoration behavior while maintaining the functools.wraps functionality.
python/tvm/_ffi/base.py
Outdated
| The wrapped function | ||
| """ | ||
| import decorator | ||
| @functools.wraps(func) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we confirm functools.wraps can do the job, perhaps we can simply replace all the callsite with functools and remove this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit has replaced all decorator call sites with functools.wraps, cc @tqchen
Remove the custom decorate function from base.py and update multiple files to use functools.wraps directly. This change eliminates the need for a custom decorator implementation and simplifies the codebase by leveraging Python's built-in functools module.
|
great, we can merge once ci is green |
|
Thanks @LeiWang1999 for great work, this is now merged! |
* Refactor decorate function to use functools.wraps Replace decorator package with functools.wraps for simpler and more standard function wrapping. This change removes an external dependency and uses Python's built-in functools module for function decoration. * Remove decorator package dependency Remove the decorator package from various installation scripts and requirements files. This follows the previous refactoring of decorators to use functools.wraps, eliminating an external dependency and simplifying the project's package requirements. * Modify decorate function to support more flexible function wrapping Update the decorate function to create a wrapper that allows more flexible function decoration. The new implementation passes the original function as the first argument to the wrapped function, enabling more dynamic decoration behavior while maintaining the functools.wraps functionality. * Remove decorate function and replace with functools.wraps Remove the custom decorate function from base.py and update multiple files to use functools.wraps directly. This change eliminates the need for a custom decorator implementation and simplifies the codebase by leveraging Python's built-in functools module. * Remove generic_func.py as upstream did * Fix dominant issues of decorator * fix for pickle memoize
Remove the 'decorator' package from various installation scripts, requirements, and documentation. Update the FFI base module to use a local decorator implementation instead of the external package.
Previous pull request #17652